our $AUTHORITY = 'cpan:STEVAN';
use base 'Moose::Meta::TypeConstraint';
+use Moose::Meta::TypeConstraint::Parameterized;
__PACKAGE__->meta->add_attribute('constraint_generator' => (
accessor => 'constraint_generator',
};
}
+sub parameterize {
+ my ($self, $args) = @_;
+
+ unless(ref $args eq 'ARRAY') {
+ Moose->throw_error(
+ "The type constraint ".$self->name." requires it's argument to be an ArrayRef"
+ );
+ }
+
+ my $contained_tc = find_or_create_isa_type_constraint($args->[0]);
+
+ return Moose::Meta::TypeConstraint::Parameterized->new(
+ name => $self->name .'['.$contained_tc->name.']',
+ parent => $self,
+ type_parameter => find_or_create_isa_type_constraint($contained_tc),
+ );
+}
+
1;
my $subtype2 = subtype 'New2' => as $subtype1;
ok $subtype2 => 'made a subtype of our subtype';
+
+# testing the parameterize method
+
+{
+ package Test::Moose::Meta::TypeConstraint::Parameterizable;
+
+ use Moose;
+ use Moose::Util::TypeConstraints;
+
+ my $parameterizable = subtype 'parameterizable_hashref',
+ as 'HashRef';
+
+ my $parameterized = subtype 'parameterized_hashref',
+ as 'HashRef[Int]';
+}
\ No newline at end of file