From: gfx Date: Fri, 30 Oct 2009 00:51:53 +0000 (+0900) Subject: Add '|' operator to Meta::TypeConstraint (experimental) X-Git-Tag: 0.40_03~6 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8adc0b23d04403eebb4e296a440079d8b475ebc0;p=gitmo%2FMouse.git Add '|' operator to Meta::TypeConstraint (experimental) --- diff --git a/lib/Mouse/Meta/TypeConstraint.pm b/lib/Mouse/Meta/TypeConstraint.pm index a35b4d0..0526163 100644 --- a/lib/Mouse/Meta/TypeConstraint.pm +++ b/lib/Mouse/Meta/TypeConstraint.pm @@ -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 ();