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