because Structurable is not a word
[gitmo/MooseX-Types-Structured.git] / lib / MooseX / Meta / TypeConstraint / Structured / Generator.pm
CommitLineData
2dfe3b71 1package MooseX::Meta::TypeConstraint::Structured::Generator;
bfef1b30 2
3use strict;
4use warnings;
5
6use metaclass;
7
66c84636 8use base 'Moose::Meta::TypeConstraint';
bfef1b30 9use Moose::Util::TypeConstraints ();
bfef1b30 10
66c84636 11__PACKAGE__->meta->add_attribute('structured_type' => (
12 accessor => 'structured_type',
13 predicate => 'has_structured_type',
14));
15
bfef1b30 16sub parse_parameter_str {
7e2f0558 17 my ($self, $type_str) = @_;
18 return $self->structured_type->parse_parameter_str($type_str);
bfef1b30 19}
20
21sub parameterize {
011bacc6 22 my ($self, @contained_tcs) = @_;
23 my $tc_name = $self->name .'['. join(',', map {$_->name} @contained_tcs) .']';
bfef1b30 24
7e2f0558 25 return $self->structured_type->new(
bfef1b30 26 name => $tc_name,
7e2f0558 27 parent => $self->parent,
bfef1b30 28 package_defined_in => __PACKAGE__,
29 signature => \@contained_tcs,
30 );
bfef1b30 31}
32
bfef1b30 331;