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 Try to see if the type constraint has yet been defined and if so create it.
53 if(my $tc = $self->{instance}) {
55 } elsif( my $new_tc = Moose::Util::TypeConstraints::find_type_constraint($self->name)) {
56 $self->{instance} = $new_tc;
65 Make sure that if a type hasn't been defined yet when Moose wants to inline it,
66 we don't allow inlining.
72 if(my $type_constraint = $self->__autovivify) {
73 return $type_constraint->can_be_inlined;
81 Try to autovivify and delegate
86 my ($self, @args) = @_;
87 my ($method) = our $AUTOLOAD =~ /([^:]+)$/;
89 if(my $type_constraint = $self->__autovivify) {
90 return $type_constraint->$method(@args);
92 croak "Method '$method' is not supported for " . $self->name;
98 Moose::Meta::TypeConstraint::Parameterizable complains if this isn't here. TODO
109 L<MooseX::Types::Moose>,
110 L<Moose::Util::TypeConstraints>,
111 L<Moose::Meta::TypeConstraint>,
116 This program is free software; you can redistribute it and/or modify
117 it under the same terms as perl itself.