Add '|' operator to Meta::TypeConstraint (experimental)
gfx [Fri, 30 Oct 2009 00:51:53 +0000 (09:51 +0900)]
lib/Mouse/Meta/TypeConstraint.pm

index a35b4d0..0526163 100644 (file)
@@ -3,6 +3,14 @@ use Mouse::Util qw(:meta); # enables strict and warnings
 
 use overload
     '""'     => sub { $_[0]->name },   # stringify to tc name
+
+    '|'      => sub {                  # or-combination
+        require Mouse::Util::TypeConstraints;
+        return Mouse::Util::TypeConstraints::find_or_parse_type_constraint(
+            "$_[0] | $_[1]",
+        );
+    },
+
     fallback => 1;
 
 use Carp         ();