find_type_constraint now DWIms when given an object
Yuval Kogman [Sat, 12 Apr 2008 14:56:27 +0000 (14:56 +0000)]
lib/Moose/Util/TypeConstraints.pm

index c79046e..73ecf48 100644 (file)
@@ -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;