From: John Napiorkowski Date: Thu, 11 Sep 2008 16:45:36 +0000 (+0000) Subject: finished parameterized method, tests and converted Moose::Util::TypeConstraints to... X-Git-Tag: 0.58~37^2~16 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=af6941770334c72d83b12fcb0f45a55b09dfaaea;p=gitmo%2FMoose.git finished parameterized method, tests and converted Moose::Util::TypeConstraints to use it --- diff --git a/lib/Moose/Meta/TypeConstraint/Parameterizable.pm b/lib/Moose/Meta/TypeConstraint/Parameterizable.pm index a8e32a3..93d0cc9 100644 --- a/lib/Moose/Meta/TypeConstraint/Parameterizable.pm +++ b/lib/Moose/Meta/TypeConstraint/Parameterizable.pm @@ -41,6 +41,11 @@ sub _can_coerce_constraint_from { }; } +sub parse_parameter_str { + my ($self, $type_str) = @_; + return find_or_create_isa_type_constraint($type_str); +} + sub parameterize { my ($self, @args) = @_; @@ -86,6 +91,10 @@ Moose::Meta::TypeConstraint::Parameterizable - Higher Order type constraints for =item B +=item B + +Given a string, convert it to a Perl structure. + =item B Given an array of type constraints, parameterize the current type constraint. diff --git a/lib/Moose/Util/TypeConstraints.pm b/lib/Moose/Util/TypeConstraints.pm index ac6802c..f8ccabe 100644 --- a/lib/Moose/Util/TypeConstraints.pm +++ b/lib/Moose/Util/TypeConstraints.pm @@ -140,14 +140,14 @@ sub create_parameterized_type_constraint ($) { sub _create_parameterized_type_constraint { my ($tc_name, $base_type_tc, $type_parameter_str) = @_; - my @type_parameters_tc = map {find_or_create_isa_type_constraint($_)} ($type_parameter_str); if($base_type_tc->can('parameterize')) { + my @type_parameters_tc = $base_type_tc->parse_parameter_str($type_parameter_str); return $base_type_tc->parameterize($tc_name,@type_parameters_tc); } else { return Moose::Meta::TypeConstraint::Parameterized->new( name => $tc_name, parent => $base_type_tc, - type_parameter => $type_parameters_tc[0], + type_parameter => find_or_create_isa_type_constraint[$type_parameter_str], ); } }