X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=blobdiff_plain;f=lib%2FMouse%2FPurePerl.pm;h=f2802dbb5f057854fd5b6edbb9f4d92d50117db1;hp=8644c935b40466e236d47c96d4ac7f8d17a02624;hb=1d5ecd5f15a0f418bee471c00af2357ba63b99ba;hpb=935400114c35ad1b2481c48ff471e180e9c93d93 diff --git a/lib/Mouse/PurePerl.pm b/lib/Mouse/PurePerl.pm index 8644c93..f2802db 100644 --- a/lib/Mouse/PurePerl.pm +++ b/lib/Mouse/PurePerl.pm @@ -77,9 +77,23 @@ sub get_code_ref{ package Mouse::Util::TypeConstraints; +sub _generate_class_type_for{ + my($for_class, $name) = @_; + + my $predicate = sub{ Scalar::Util::blessd($_[0]) && $_[0]->isa($for_class) }; + + if(defined $name){ + no strict 'refs'; + *{ caller() . '::' . $name } = $predicate; + return; + } + + return $predicate; +} + + sub Any { 1 } sub Item { 1 } -sub Maybe { 1 } sub Bool { $_[0] ? $_[0] eq '1' : 1 } sub Undef { !defined($_[0]) }