regsiter maybe_type
Ricardo SIGNES [Wed, 21 Jan 2009 23:04:09 +0000 (23:04 +0000)]
lib/Moose/Util/TypeConstraints.pm

index aa9da35..b9af74e 100644 (file)
@@ -305,14 +305,16 @@ sub role_type ($;$) {
 sub maybe_type {
     my ($type_parameter) = @_;
 
-    Moose::Meta::TypeConstraint->new(
-        parent               => find_type_constraint('Item'),
-        constraint           => sub {
-            my $check = $type_parameter->_compiled_type_constraint;
-            return 1 if not(defined($_)) || $check->($_);
-            return;
-        }
-    )
+    register_type_constraint(
+      Moose::Meta::TypeConstraint->new(
+          parent               => find_type_constraint('Item'),
+          constraint           => sub {
+              my $check = $type_parameter->_compiled_type_constraint;
+              return 1 if not(defined($_)) || $check->($_);
+              return;
+          }
+      )
+    );
 }
 
 sub coerce {