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('Object', where { $_->isa($container_type) })
36 before 'process_options_for_provides' => sub {
37 my ($self, $options) = @_;
39 if (exists $options->{isa}) {
40 my $type = $options->{isa};
41 if ($type =~ /^(.*)\[(.*)\]$/) {
43 my $container_type = $2;
44 $options->{isa} = $core_type;
45 $options->{container_type} = $container_type;
68 All complex software has bugs lurking in it, and this module is no
69 exception. If you find a bug please either email me, or add the bug
74 Stevan Little E<lt>stevan@iinteractive.comE<gt>
76 =head1 COPYRIGHT AND LICENSE
78 Copyright 2007 by Infinity Interactive, Inc.
80 L<http://www.iinteractive.com>
82 This library is free software; you can redistribute it and/or modify
83 it under the same terms as Perl itself.