Add '|' operator to Meta::TypeConstraint (experimental)
[gitmo/Mouse.git] / 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         ();