1 package MooseX::Types::UndefinedType;
6 MooseX::Types::UndefinedType - Represents a not yet defined type
13 use Moose::Util::TypeConstraints ();
14 use Carp::Clan qw( ^MooseX::Types );
16 use overload '""' => sub { shift->name },
21 Whenever a type handle function (e.g. C<Int()> can't find a type
22 constraint under it's full name, it assumes it has not yet been defined.
23 It will then return an instance of this class, handling only
24 stringification, name and possible identification of undefined types.
26 Later, when you try to use the Undefined Type Constraint, autovivification will
33 Takes a full type name as argument and returns an instance of this
39 return bless { name => $_[1] }, $_[0];
44 Returns the stored type name.
54 Always returns false. Needed for compatbility with Moose 2.0100+.
58 sub can_be_inlined { 0 }
62 Try to see if the type constraint has yet been defined and if so create it.
68 if(my $tc = $self->{instance}) {
70 } elsif( my $new_tc = Moose::Util::TypeConstraints::find_type_constraint($self->name)) {
71 $self->{instance} = $new_tc;
80 Try to autovivify and delegate
85 my ($self, @args) = @_;
86 my ($method) = our $AUTOLOAD =~ /([^:]+)$/;
88 if(my $type_constraint = $self->__autovivify) {
89 return $type_constraint->$method(@args);
91 croak "Method '$method' is not supported for " . $self->name;
97 Moose::Meta::TypeConstraint::Parameterizable complains if this isn't here. TODO
108 L<MooseX::Types::Moose>,
109 L<Moose::Util::TypeConstraints>,
110 L<Moose::Meta::TypeConstraint>,
115 See L<MooseX::Types/AUTHOR>.
119 This program is free software; you can redistribute it and/or modify
120 it under the same terms as perl itself.