1 package MooseX::AttributeHelpers::MethodProvider::Array;
5 our $AUTHORITY = 'cpan:STEVAN';
7 with 'MooseX::AttributeHelpers::MethodProvider::List';
10 my ($attr, $reader, $writer) = @_;
12 if ($attr->has_container_type) {
13 my $container_type_constraint = $attr->container_type_constraint;
15 my $instance = CORE::shift;
16 $container_type_constraint->check($_)
17 || confess "Value " . ($_||'undef') . " did not pass container type constraint"
19 CORE::push @{$reader->($instance)} => @_;
24 my $instance = CORE::shift;
25 CORE::push @{$reader->($instance)} => @_;
31 my ($attr, $reader, $writer) = @_;
33 CORE::pop @{$reader->($_[0])}
37 sub unshift : method {
38 my ($attr, $reader, $writer) = @_;
39 if ($attr->has_container_type) {
40 my $container_type_constraint = $attr->container_type_constraint;
42 my $instance = CORE::shift;
43 $container_type_constraint->check($_)
44 || confess "Value " . ($_||'undef') . " did not pass container type constraint"
46 CORE::unshift @{$reader->($instance)} => @_;
51 my $instance = CORE::shift;
52 CORE::unshift @{$reader->($instance)} => @_;
58 my ($attr, $reader, $writer) = @_;
60 CORE::shift @{$reader->($_[0])}
65 my ($attr, $reader, $writer) = @_;
67 @{$reader->($_[0])} = ()
72 my ($attr, $reader, $writer) = @_;
74 $reader->($_[0])->[$_[1]]
79 my ($attr, $reader, $writer) = @_;
80 if ($attr->has_container_type) {
81 my $container_type_constraint = $attr->container_type_constraint;
83 ($container_type_constraint->check($_[2]))
84 || confess "Value " . ($_[2]||'undef') . " did not pass container type constraint";
85 $reader->($_[0])->[$_[1]] = $_[2]
90 $reader->($_[0])->[$_[1]] = $_[2]
103 MooseX::AttributeHelpers::MethodProvider::Array
107 This is a role which provides the method generators for
108 L<MooseX::AttributeHelpers::Collection::Array>.
118 =head1 PROVIDED METHODS
120 This module also consumes the B<List> method providers, to
121 see those provied methods, refer to that documentation.
143 All complex software has bugs lurking in it, and this module is no
144 exception. If you find a bug please either email me, or add the bug
149 Stevan Little E<lt>stevan@iinteractive.comE<gt>
151 =head1 COPYRIGHT AND LICENSE
153 Copyright 2007 by Infinity Interactive, Inc.
155 L<http://www.iinteractive.com>
157 This library is free software; you can redistribute it and/or modify
158 it under the same terms as Perl itself.