1 package MooseX::AttributeHelpers::MethodProvider::Array;
6 if ($attr->has_container_type) {
7 my $container_type_constraint = $attr->container_type_constraint;
9 my $instance = CORE::shift;
10 $container_type_constraint->check($_)
11 || confess "Value " . ($_||'undef') . " did not pass container type constraint"
13 CORE::push @{$attr->get_value($instance)} => @_;
18 my $instance = CORE::shift;
19 CORE::push @{$attr->get_value($instance)} => @_;
27 CORE::pop @{$attr->get_value($_[0])}
31 sub unshift : method {
33 if ($attr->has_container_type) {
34 my $container_type_constraint = $attr->container_type_constraint;
36 my $instance = CORE::shift;
37 $container_type_constraint->check($_)
38 || confess "Value " . ($_||'undef') . " did not pass container type constraint"
40 CORE::unshift @{$attr->get_value($instance)} => @_;
45 my $instance = CORE::shift;
46 CORE::unshift @{$attr->get_value($instance)} => @_;
54 CORE::shift @{$attr->get_value($_[0])}
61 $attr->get_value($_[0])->[$_[1]]
67 if ($attr->has_container_type) {
68 my $container_type_constraint = $attr->container_type_constraint;
70 ($container_type_constraint->check($_[2]))
71 || confess "Value " . ($_[2]||'undef') . " did not pass container type constraint";
72 $attr->get_value($_[0])->[$_[1]] = $_[2]
77 $attr->get_value($_[0])->[$_[1]] = $_[2]
85 scalar @{$attr->get_value($_[0])}
92 scalar @{$attr->get_value($_[0])} ? 1 : 0
99 my ($instance, $predicate) = @_;
100 foreach my $val (@{$attr->get_value($instance)}) {
101 return $val if $predicate->($val);
110 my ($instance, $f) = @_;
111 CORE::map { $f->($_) } @{$attr->get_value($instance)}
118 my ($instance, $predicate) = @_;
119 CORE::grep { $predicate->($_) } @{$attr->get_value($instance)}
131 MooseX::AttributeHelpers::MethodProvider::Array
135 This is a role which provides the method generators for
136 L<MooseX::AttributeHelpers::Collection::Array>.
146 =head1 PROVIDED METHODS
176 All complex software has bugs lurking in it, and this module is no
177 exception. If you find a bug please either email me, or add the bug
182 Stevan Little E<lt>stevan@iinteractive.comE<gt>
184 =head1 COPYRIGHT AND LICENSE
186 Copyright 2007 by Infinity Interactive, Inc.
188 L<http://www.iinteractive.com>
190 This library is free software; you can redistribute it and/or modify
191 it under the same terms as Perl itself.