just restored some bits so that tests all pass, incase anyone wants to play with...
[gitmo/MooseX-Types-Structured.git] / lib / MooseX / Meta / TypeConstraint / Structured / Generator.pm
1 package MooseX::Meta::TypeConstraint::Structured::Generator;
2
3 use strict;
4 use warnings;
5
6 use metaclass;
7
8 use base 'Moose::Meta::TypeConstraint';
9 use Moose::Util::TypeConstraints ();
10
11 __PACKAGE__->meta->add_attribute('structured_type' => (
12     accessor  => 'structured_type',
13     predicate => 'has_structured_type',
14 ));
15
16 sub parse_parameter_str {
17         my ($self, $type_str) = @_;
18         return $self->structured_type->parse_parameter_str($type_str);
19 }
20
21 sub parameterize {
22         my ($self, $parameter_string) = @_;
23         my @contained_tcs = $self->parse_parameter_str($parameter_string);
24         my $tc_name = $self->name .'['. join(',', map {$_->name} @contained_tcs) .']';
25         
26         return $self->structured_type->new(
27                 name => $tc_name,
28                 parent => $self->parent,
29                 package_defined_in => __PACKAGE__,
30                 signature => \@contained_tcs,
31         );                      
32 }
33
34 1;