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