move repository to http://github.com/moose/MooseX-Types
[gitmo/MooseX-Types.git] / lib / MooseX / Types / UndefinedType.pm
index 58f5d3e..9db7461 100644 (file)
@@ -1,7 +1,5 @@
 package MooseX::Types::UndefinedType;
 
-=cut
-
 use warnings;
 use strict;
 
@@ -13,9 +11,9 @@ use overload '""'     => sub { shift->name },
 
 =head1 DESCRIPTION
 
-Whenever a type handle function (e.g. C<Int()> can't find a type 
+Whenever a type handle function (e.g. C<Int()> can't find a type
 constraint under it's full name, it assumes it has not yet been defined.
-It will then return an instance of this class, handling only 
+It will then return an instance of this class, handling only
 stringification, name and possible identification of undefined types.
 
 Later, when you try to use the Undefined Type Constraint, autovivification will
@@ -44,14 +42,6 @@ sub name {
     return $_[0]->{name};
 }
 
-=head2 can_be_inlined
-
-Always returns false. Needed for compatbility with Moose 2.0100+.
-
-=cut
-
-sub can_be_inlined { 0 }
-
 =head2 __autovivify
 
 Try to see if the type constraint has yet been defined and if so create it.
@@ -70,6 +60,22 @@ sub __autovivify {
     }
 }
 
+=head2 can_be_inlined
+
+Make sure that if a type hasn't been defined yet when Moose wants to inline it,
+we don't allow inlining.
+
+=cut
+
+sub can_be_inlined {
+    my $self = shift;
+    if(my $type_constraint = $self->__autovivify) {
+        return $type_constraint->can_be_inlined;
+    } else {
+        return;
+    }
+}
+
 =head2 AUTOLOAD
 
 Try to autovivify and delegate
@@ -78,7 +84,7 @@ Try to autovivify and delegate
 
 sub AUTOLOAD {
     my ($self, @args)  = @_;
-    my ($method) = our $AUTOLOAD =~ /([^:]+)$/;    
+    my ($method) = our $AUTOLOAD =~ /([^:]+)$/;
 
     if(my $type_constraint = $self->__autovivify) {
         return $type_constraint->$method(@args);
@@ -101,7 +107,7 @@ sub DESTROY {
 =head1 SEE ALSO
 
 L<MooseX::Types::Moose>,
-L<Moose::Util::TypeConstraints>, 
+L<Moose::Util::TypeConstraints>,
 L<Moose::Meta::TypeConstraint>,
 L<Carp::Clan>