X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMooseX%2FMeta%2FTypeConstraint%2FStructured%2FPositional.pm;h=115e25ac00e5a4aa7234e7accf0dd6b92889b8da;hb=7e2f0558073a1a9544274a76ad7530340b2c18e8;hp=f51a9d60c83fba804e467aab8c759d49eb38d030;hpb=66c846366a6ed61a4dbce42cc81063207792f685;p=gitmo%2FMooseX-Types-Structured.git diff --git a/lib/MooseX/Meta/TypeConstraint/Structured/Positional.pm b/lib/MooseX/Meta/TypeConstraint/Structured/Positional.pm index f51a9d6..115e25a 100644 --- a/lib/MooseX/Meta/TypeConstraint/Structured/Positional.pm +++ b/lib/MooseX/Meta/TypeConstraint/Structured/Positional.pm @@ -117,6 +117,33 @@ sub constraint { }; } +=head2 parse_parameter_str ($str) + +Given a $string that is the parameter information part of a parameterized +constraint, parses it for internal constraint information. For example: + + MyType[Int,Int,Str] + +has a parameter string of "Int,Int,Str" (whitespace will automatically be +removed during normalization that happens in L) +and we need to convert that to ['Int','Int','Str'] which then has any type +constraints converted to true objects. + +=cut + +{ + my $comma = qr{,}; + my $indirection = qr{=>}; + my $divider_ops = qr{ $comma | $indirection }x; + my $structure_divider = qr{\s* $divider_ops \s*}x; + + sub parse_parameter_str { + my ($class, $type_str) = @_; + my @type_strs = split($structure_divider, $type_str); + return map { Moose::Util::TypeConstraints::find_or_create_isa_type_constraint($_) } @type_strs; + } +} + =head2 signature_equals Check that the signature equals another signature.