- moved the ->parameterize tests to own test suite
[gitmo/Moose.git] / lib / Moose / Meta / TypeConstraint / Parameterizable.pm
index 93d0cc9..4fdfbe6 100644 (file)
@@ -10,6 +10,7 @@ our $AUTHORITY = 'cpan:STEVAN';
 
 use base 'Moose::Meta::TypeConstraint';
 use Moose::Meta::TypeConstraint::Parameterized;
+use Moose::Util::TypeConstraints ();
 
 __PACKAGE__->meta->add_attribute('constraint_generator' => (
     accessor  => 'constraint_generator',
@@ -43,30 +44,22 @@ sub _can_coerce_constraint_from {
 
 sub parse_parameter_str {
     my ($self, $type_str) = @_;
-    return find_or_create_isa_type_constraint($type_str);
+    return Moose::Util::TypeConstraints::find_or_create_isa_type_constraint($type_str);
 }
 
 sub parameterize {
-       my ($self, @args) = @_;
-    
-    ## ugly hacking to deal with tc naming normalization issue
-    my ($tc_name, $contained_tc);
-    if (ref $args[0]) {
-        $contained_tc = shift @args;
-        $tc_name = $self->name .'['. $contained_tc->name .']';
-    } else {
-        ($tc_name, $contained_tc) = @args;
+       my ($self, $contained_tc) = @_;
+
+       if($contained_tc->isa('Moose::Meta::TypeConstraint')) {
+        my $tc_name = $self->name .'['. $contained_tc->name .']';        
+        return Moose::Meta::TypeConstraint::Parameterized->new(
+            name           => $tc_name,
+            parent         => $self,
+            type_parameter => $contained_tc,
+        );                     
+       } else {
+        Moose->throw_error("The type parameter must be a Moose meta type");
     }
-       
-       unless($contained_tc->isa('Moose::Meta::TypeConstraint')) {
-               Moose->throw_error("The type parameter must be a Moose meta type");
-       }
-       
-    return Moose::Meta::TypeConstraint::Parameterized->new(
-        name           => $tc_name,
-        parent         => $self,
-        type_parameter => $contained_tc,
-    ); 
 }