Allow type coercions to be declared from anon types
Yuval Kogman [Fri, 18 Apr 2008 15:51:40 +0000 (15:51 +0000)]
lib/Moose/Meta/TypeCoercion.pm

index 1412ae7..26d5420 100644 (file)
@@ -43,7 +43,7 @@ sub compile_type_coercion {
     my @coercions;
     while (@coercion_map) {
         my ($constraint_name, $action) = splice(@coercion_map, 0, 2);
-        my $type_constraint = Moose::Util::TypeConstraints::find_or_parse_type_constraint($constraint_name);
+        my $type_constraint = ref $constraint_name ? $constraint_name : Moose::Util::TypeConstraints::find_or_parse_type_constraint($constraint_name);
         (defined $type_constraint)
             || confess "Could not find the type constraint ($constraint_name) to coerce from";
         push @coercions => [