From: Yuval Kogman Date: Sat, 12 Apr 2008 14:56:27 +0000 (+0000) Subject: find_type_constraint now DWIms when given an object X-Git-Tag: 0_55~236 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=eeedfc8a999fdb202a442719bcca75ce417eff36;p=gitmo%2FMoose.git find_type_constraint now DWIms when given an object --- diff --git a/lib/Moose/Util/TypeConstraints.pm b/lib/Moose/Util/TypeConstraints.pm index c79046e..73ecf48 100644 --- a/lib/Moose/Util/TypeConstraints.pm +++ b/lib/Moose/Util/TypeConstraints.pm @@ -213,7 +213,15 @@ sub find_or_create_type_constraint ($;$) { ## exported functions ... ## -------------------------------------------------------- -sub find_type_constraint ($) { $REGISTRY->get_type_constraint(@_) } +sub find_type_constraint ($) { + my $type = shift; + + if ( blessed $type and $type->isa("Moose::Meta::TypeConstraint") ) { + return $type; + } else { + return $REGISTRY->get_type_constraint($type); + } +} sub register_type_constraint ($) { my $constraint = shift;