70cde118000d570adb0a895ab2407e37d844bf1f
[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     -excludes => [
10         qw(
11             _minimum_arguments
12             _maximum_arguments
13             _inline_check_arguments
14             _inline_optimized_set_new_value
15             _return_value
16             )
17     ],
18 };
19
20 sub _minimum_arguments { 1 }
21
22 sub _maximum_arguments { 1 }
23
24 sub _inline_check_arguments {
25     my $self = shift;
26
27     return $self->_inline_check_var_is_valid_index('$_[0]');
28 }
29
30 sub _adds_members { 0 }
31
32 sub _potential_value {
33     my $self = shift;
34     my ($slot_access) = @_;
35
36     return '(do { '
37              . 'my @potential = @{ (' . $slot_access . ') }; '
38              . '@return = splice @potential, $_[0], 1; '
39              . '\@potential; '
40          . '})';
41 }
42
43 sub _inline_optimized_set_new_value {
44     my $self = shift;
45     my ($inv, $new, $slot_access) = @_;
46
47     return '@return = splice @{ (' . $slot_access . ') }, $_[0], 1;';
48 }
49
50 sub _return_value {
51     my $self = shift;
52     my ($slot_access) = @_;
53
54     return '$return[0]';
55 }
56
57 no Moose::Role;
58
59 1;