2 package MooseX::AttributeHelpers::Collection;
4 use Moose::Util::TypeConstraints;
7 our $AUTHORITY = 'cpan:STEVAN';
9 extends 'MooseX::AttributeHelpers::Base';
11 has 'container_type' => (
14 predicate => 'has_container_type',
17 has 'container_type_constraint' => (
19 isa => 'Moose::Meta::TypeConstraint',
23 ($self->has_container_type)
24 || confess "You cannot create a container_type_constraint if you dont have a container type";
26 my $container_type = $self->container_type;
27 my $constraint = find_type_constraint($container_type);
30 # I am not sure DWIM-ery is a good thing
31 # here, so i am going to err on the side
32 # of caution, and blow up if you have
33 # not made a type constraint for this yet.
36 || confess "You must predefine the '$container_type' constraint before you can use it as a container type";
42 before 'process_options_for_provides' => sub {
43 my ($self, $options) = @_;
45 if (exists $options->{isa}) {
46 my $type = $options->{isa};
47 if ($type =~ /^(.*)\[(.*)\]$/) {
49 my $container_type = $2;
50 $options->{isa} = $core_type;
51 $options->{container_type} = $container_type;
57 no Moose::Util::TypeConstraints;
75 All complex software has bugs lurking in it, and this module is no
76 exception. If you find a bug please either email me, or add the bug
81 Stevan Little E<lt>stevan@iinteractive.comE<gt>
83 =head1 COPYRIGHT AND LICENSE
85 Copyright 2007 by Infinity Interactive, Inc.
87 L<http://www.iinteractive.com>
89 This library is free software; you can redistribute it and/or modify
90 it under the same terms as Perl itself.