Use dzil Authority plugin - remove $AUTHORITY from code
[gitmo/Moose.git] / lib / Moose / Meta / Method / Accessor / Native / Array / pop.pm
CommitLineData
a7821be5 1package Moose::Meta::Method::Accessor::Native::Array::pop;
2
3use strict;
4use warnings;
5
8b9641b8 6use Moose::Role;
7
8with '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
17sub _maximum_arguments { 0 }
18
19sub _adds_members { 0 }
20
21sub _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 30sub _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 37sub _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
44sub _return_value {
53a4677c 45 my $self = shift;
46 my ($slot_access) = @_;
a7821be5 47
53a4677c 48 return '$old';
a7821be5 49}
50
8b9641b8 51no Moose::Role;
52
a7821be5 531;