1 package MooseX::Types::UndefinedType;
8 use Moose::Util::TypeConstraints ();
9 use Carp::Clan qw( ^MooseX::Types );
11 use overload '""' => sub { shift->name },
16 Whenever a type handle function (e.g. C<Int()> can't find a type
17 constraint under it's full name, it assumes it has not yet been defined.
18 It will then return an instance of this class, handling only
19 stringification, name and possible identification of undefined types.
21 Later, when you try to use the Undefined Type Constraint, autovivification will
28 Takes a full type name as argument and returns an instance of this
34 return bless { name => $_[1] }, $_[0];
39 Returns the stored type name.
49 Always returns false. Needed for compatbility with Moose 2.0100+.
53 sub can_be_inlined { 0 }
57 Try to see if the type constraint has yet been defined and if so create it.
63 if(my $tc = $self->{instance}) {
65 } elsif( my $new_tc = Moose::Util::TypeConstraints::find_type_constraint($self->name)) {
66 $self->{instance} = $new_tc;
75 Try to autovivify and delegate
80 my ($self, @args) = @_;
81 my ($method) = our $AUTOLOAD =~ /([^:]+)$/;
83 if(my $type_constraint = $self->__autovivify) {
84 return $type_constraint->$method(@args);
86 croak "Method '$method' is not supported for " . $self->name;
92 Moose::Meta::TypeConstraint::Parameterizable complains if this isn't here. TODO
103 L<MooseX::Types::Moose>,
104 L<Moose::Util::TypeConstraints>,
105 L<Moose::Meta::TypeConstraint>,
110 This program is free software; you can redistribute it and/or modify
111 it under the same terms as perl itself.