43e6cd46e5fe1577f6590632bdddec7eedf994fc
[gitmo/Moose.git] / lib / Moose / Meta / Method / Accessor / Native / Array / delete.pm
1 package Moose::Meta::Method::Accessor::Native::Array::delete;
2
3 use strict;
4 use warnings;
5
6 use Moose::Role;
7
8 with 'Moose::Meta::Method::Accessor::Native::Array::Writer';
9
10 sub _minimum_arguments { 1 }
11
12 sub _maximum_arguments { 1 }
13
14 sub _inline_check_arguments {
15     my $self = shift;
16
17     return $self->_inline_check_var_is_valid_index('$_[0]');
18 }
19
20 sub _adds_members { 0 }
21
22 sub _potential_value {
23     my $self = shift;
24     my ($slot_access) = @_;
25
26     return '(do { '
27              . 'my @potential = @{ (' . $slot_access . ') }; '
28              . '@return = splice @potential, $_[0], 1; '
29              . '\@potential; '
30          . '})';
31 }
32
33 sub _inline_optimized_set_new_value {
34     my $self = shift;
35     my ($inv, $new, $slot_access) = @_;
36
37     return '@return = splice @{ (' . $slot_access . ') }, $_[0], 1;';
38 }
39
40 sub _return_value {
41     my $self = shift;
42     my ($slot_access) = @_;
43
44     return '$return[0]';
45 }
46
47 no Moose::Role;
48
49 1;