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