1 package MooseX::Types::UndefinedType;
6 use Moose::Util::TypeConstraints ();
7 use Carp::Clan qw( ^MooseX::Types );
9 use overload '""' => sub { shift->name },
14 Whenever a type handle function (e.g. C<Int()> can't find a type
15 constraint under it's full name, it assumes it has not yet been defined.
16 It will then return an instance of this class, handling only
17 stringification, name and possible identification of undefined types.
19 Later, when you try to use the Undefined Type Constraint, autovivification will
26 Takes a full type name as argument and returns an instance of this
32 return bless { name => $_[1] }, $_[0];
37 Returns the stored type name.
47 Always returns false. Needed for compatbility with Moose 2.0100+.
51 sub can_be_inlined { 0 }
55 Try to see if the type constraint has yet been defined and if so create it.
61 if(my $tc = $self->{instance}) {
63 } elsif( my $new_tc = Moose::Util::TypeConstraints::find_type_constraint($self->name)) {
64 $self->{instance} = $new_tc;
73 Try to autovivify and delegate
78 my ($self, @args) = @_;
79 my ($method) = our $AUTOLOAD =~ /([^:]+)$/;
81 if(my $type_constraint = $self->__autovivify) {
82 return $type_constraint->$method(@args);
84 croak "Method '$method' is not supported for " . $self->name;
90 Moose::Meta::TypeConstraint::Parameterizable complains if this isn't here. TODO
101 L<MooseX::Types::Moose>,
102 L<Moose::Util::TypeConstraints>,
103 L<Moose::Meta::TypeConstraint>,
108 This program is free software; you can redistribute it and/or modify
109 it under the same terms as perl itself.