Commit | Line | Data |
a7821be5 |
1 | package Moose::Meta::Method::Accessor::Native::Array::shift; |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
245478d5 |
6 | our $VERSION = '1.19'; |
a7821be5 |
7 | $VERSION = eval $VERSION; |
8 | our $AUTHORITY = 'cpan:STEVAN'; |
9 | |
8b9641b8 |
10 | use Moose::Role; |
11 | |
12 | with 'Moose::Meta::Method::Accessor::Native::Array::Writer' => { |
13 | -excludes => [ |
14 | qw( |
15 | _maximum_arguments |
16 | _inline_capture_return_value |
17 | _inline_optimized_set_new_value |
18 | _return_value |
19 | ) |
20 | ] |
21 | }; |
a7821be5 |
22 | |
23 | sub _maximum_arguments { 0 } |
24 | |
25 | sub _adds_members { 0 } |
26 | |
27 | sub _potential_value { |
28 | my ( $self, $slot_access ) = @_; |
29 | |
1d06edbf |
30 | return "[ \@{ ($slot_access) } > 1 ? \@{ ($slot_access) }[ 1 .. \$#{ ($slot_access) } ] : () ]"; |
a7821be5 |
31 | } |
32 | |
e32b7489 |
33 | sub _inline_capture_return_value { |
a7821be5 |
34 | my ( $self, $slot_access ) = @_; |
35 | |
e32b7489 |
36 | return "my \$old = ${slot_access}->[0];"; |
37 | } |
38 | |
39 | sub _inline_optimized_set_new_value { |
40 | my ( $self, $inv, $new, $slot_access ) = @_; |
41 | |
1d06edbf |
42 | return "shift \@{ ($slot_access) };"; |
a7821be5 |
43 | } |
44 | |
45 | sub _return_value { |
e32b7489 |
46 | my ( $self, $slot_access ) = @_; |
a7821be5 |
47 | |
e32b7489 |
48 | return 'return $old'; |
a7821be5 |
49 | } |
50 | |
8b9641b8 |
51 | no Moose::Role; |
52 | |
a7821be5 |
53 | 1; |