allow inlining if the type has been subsequently defined
Jesse Luehrs [Thu, 19 May 2011 14:56:39 +0000 (09:56 -0500)]
lib/MooseX/Types/UndefinedType.pm

index e4ed59d..97e4031 100644 (file)
@@ -42,14 +42,6 @@ sub name {
     return $_[0]->{name};
 }
 
-=head2 can_be_inlined
-
-Always returns false. Needed for compatibility 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.
@@ -68,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