Commit | Line | Data |
---|---|---|
a7821be5 | 1 | package Moose::Meta::Method::Accessor::Native::Array::pop; |
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( _maximum_arguments | |
15 | _inline_capture_return_value | |
a486d5ad | 16 | _inline_optimized_set_new_value |
8b9641b8 | 17 | _return_value ) |
18 | ] | |
19 | }; | |
a7821be5 | 20 | |
21 | sub _maximum_arguments { 0 } | |
22 | ||
23 | sub _adds_members { 0 } | |
24 | ||
25 | sub _potential_value { | |
53a4677c | 26 | my $self = shift; |
27 | my ($slot_access) = @_; | |
a7821be5 | 28 | |
53a4677c | 29 | return '[ @{ (' . $slot_access . ') } > 1 ' |
30 | . '? @{ (' . $slot_access . ') }[0..$#{ (' . $slot_access . ') } - 1] ' | |
31 | . ': () ]'; | |
a7821be5 | 32 | } |
33 | ||
e32b7489 | 34 | sub _inline_capture_return_value { |
53a4677c | 35 | my $self = shift; |
36 | my ($slot_access) = @_; | |
a7821be5 | 37 | |
53a4677c | 38 | return 'my $old = ' . $slot_access . '->[-1];'; |
e32b7489 | 39 | } |
40 | ||
a486d5ad | 41 | sub _inline_optimized_set_new_value { |
53a4677c | 42 | my $self = shift; |
43 | my ($inv, $new, $slot_access) = @_; | |
e32b7489 | 44 | |
a486d5ad | 45 | return 'pop @{ (' . $slot_access . ') };'; |
a7821be5 | 46 | } |
47 | ||
48 | sub _return_value { | |
53a4677c | 49 | my $self = shift; |
50 | my ($slot_access) = @_; | |
a7821be5 | 51 | |
53a4677c | 52 | return '$old'; |
a7821be5 | 53 | } |
54 | ||
8b9641b8 | 55 | no Moose::Role; |
56 | ||
a7821be5 | 57 | 1; |