Add tests for coercion with native traits
[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
6our $VERSION = '1.13';
7$VERSION = eval $VERSION;
8our $AUTHORITY = 'cpan:STEVAN';
9
10use base 'Moose::Meta::Method::Accessor::Native::Array::Writer';
11
12sub _maximum_arguments { 0 }
13
14sub _adds_members { 0 }
15
16sub _potential_value {
17 my ( $self, $slot_access ) = @_;
18
19 return "( \@{ $slot_access } > 1 ? \@{ $slot_access }[ 1 .. \$#{ $slot_access } ] : () )";
20}
21
22sub _capture_old_value {
23 my ( $self, $slot_access ) = @_;
24
25 if ( $self->associated_attribute->has_trigger ) {
26 return 'my $old = $old[-1];';
27 }
28 else {
29 return "my \$old = $slot_access;";
30 }
31}
32
33sub _return_value {
34 my ( $self, $instance, $old_value ) = @_;
35
36 return 'return $old->[0]';
37}
38
391;