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);
29 $constraint = subtype(
32 $_->isa($container_type) || ($_->can('does') && $_->does($container_type))
40 before 'process_options_for_provides' => sub {
41 my ($self, $options) = @_;
43 if (exists $options->{isa}) {
44 my $type = $options->{isa};
45 if ($type =~ /^(.*)\[(.*)\]$/) {
47 my $container_type = $2;
48 $options->{isa} = $core_type;
49 $options->{container_type} = $container_type;
55 no Moose::Util::TypeConstraints;
73 All complex software has bugs lurking in it, and this module is no
74 exception. If you find a bug please either email me, or add the bug
79 Stevan Little E<lt>stevan@iinteractive.comE<gt>
81 =head1 COPYRIGHT AND LICENSE
83 Copyright 2007 by Infinity Interactive, Inc.
85 L<http://www.iinteractive.com>
87 This library is free software; you can redistribute it and/or modify
88 it under the same terms as Perl itself.