1 package MooseX::Types::UndefinedType;
5 MooseX::Types::UndefinedType - Represents a not yet defined type
12 use Moose::Util::TypeConstraints ();
13 use Carp::Clan qw( ^MooseX::Types );
15 use overload '""' => sub { shift->name },
20 Whenever a type handle function (e.g. C<Int()> can't find a type
21 constraint under it's full name, it assumes it has not yet been defined.
22 It will then return an instance of this class, handling only
23 stringification, name and possible identification of undefined types.
25 Later, when you try to use the Undefined Type Constraint, autovivification will
32 Takes a full type name as argument and returns an instance of this
38 return bless { name => $_[1] }, $_[0];
43 Returns the stored type name.
53 Try to see if the type constraint has yet been defined and if so create it.
59 if(my $tc = $self->{instance}) {
61 } elsif( my $new_tc = Moose::Util::TypeConstraints::find_type_constraint($self->name)) {
62 $self->{instance} = $new_tc;
71 Try to autovivify and delegate
76 my ($self, @args) = @_;
77 my ($method) = our $AUTOLOAD =~ /([^:]+)$/;
79 if(my $type_constraint = $self->__autovivify) {
80 return $type_constraint->$method(@args);
82 croak "Method '$method' is not supported for " . $self->name;
88 Moose::Meta::TypeConstraint::Parameterizable complains if this isn't here. TODO
99 L<MooseX::Types::Moose>,
100 L<Moose::Util::TypeConstraints>,
101 L<Moose::Meta::TypeConstraint>,
106 See L<MooseX::Types/AUTHOR>.
110 This program is free software; you can redistribute it and/or modify
111 it under the same terms as perl itself.