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);