Commit | Line | Data |
a7821be5 |
1 | package Moose::Meta::Method::Accessor::Native::Array::shift; |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | our $VERSION = '1.13'; |
7 | $VERSION = eval $VERSION; |
8 | our $AUTHORITY = 'cpan:STEVAN'; |
9 | |
10 | use base 'Moose::Meta::Method::Accessor::Native::Array::Writer'; |
11 | |
12 | sub _maximum_arguments { 0 } |
13 | |
14 | sub _adds_members { 0 } |
15 | |
16 | sub _potential_value { |
17 | my ( $self, $slot_access ) = @_; |
18 | |
19 | return "( \@{ $slot_access } > 1 ? \@{ $slot_access }[ 1 .. \$#{ $slot_access } ] : () )"; |
20 | } |
21 | |
22 | sub _capture_old_value { |
23 | my ( $self, $slot_access ) = @_; |
24 | |
25 | if ( $self->associated_attribute->has_trigger ) { |
26 | return 'my $old = $old[-1];'; |
27 | } |
28 | else { |
29 | return "my \$old = $slot_access;"; |
30 | } |
31 | } |
32 | |
33 | sub _return_value { |
34 | my ( $self, $instance, $old_value ) = @_; |
35 | |
36 | return 'return $old->[0]'; |
37 | } |
38 | |
39 | 1; |