2 package MooseX::AttributeHelpers::Collection::Array;
6 our $AUTHORITY = 'cpan:STEVAN';
8 extends 'MooseX::AttributeHelpers::Base';
10 has '+method_constructors' => (
17 push @{$attr->get_value($instance)} => @_;
22 return sub { pop @{$attr->get_value($_[0])} };
28 unshift @{$attr->get_value($instance)} => @_;
33 return sub { shift @{$attr->get_value($_[0])} };
37 return sub { $attr->get_value($_[0])->[$_[1]] };
41 return sub { $attr->get_value($_[0])->[$_[1]] = $_[2] };
45 return sub { scalar @{$attr->get_value($_[0])} };
49 return sub { scalar @{$attr->get_value($_[0])} ? 1 : 0 };
55 sub _process_options_for_provides {
56 my ($self, $options) = @_;
57 (exists $options->{isa})
58 || confess "You must define a type with the Array metaclass";
60 (find_type_constraint($options->{isa})->is_subtype_of('ArrayRef'))
61 || confess "The type constraint for a Array must be a subtype of ArrayRef";
66 # register the alias ...
67 package Moose::Meta::Attribute::Custom::Collection::Array;
68 sub register_implementation { 'MooseX::AttributeHelpers::Collection::Array' }
85 metaclass => 'Collection',
88 default => sub { [] },
90 'push' => 'add_options',
91 'pop' => 'remove_last_option',
101 All complex software has bugs lurking in it, and this module is no
102 exception. If you find a bug please either email me, or add the bug
107 Stevan Little E<lt>stevan@iinteractive.comE<gt>
109 =head1 COPYRIGHT AND LICENSE
111 Copyright 2007 by Infinity Interactive, Inc.
113 L<http://www.iinteractive.com>
115 This library is free software; you can redistribute it and/or modify
116 it under the same terms as Perl itself.