Commit | Line | Data |
---|---|---|
a7821be5 | 1 | package Moose::Meta::Method::Accessor::Native::Array::delete; |
2 | ||
3 | use strict; | |
4 | use warnings; | |
5 | ||
8b9641b8 | 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 | |
a486d5ad | 14 | _inline_optimized_set_new_value |
7f5ec80d | 15 | _return_value |
8b9641b8 | 16 | ) |
17 | ], | |
18 | }; | |
a7821be5 | 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 { | |
53a4677c | 33 | my $self = shift; |
34 | my ($slot_access) = @_; | |
a7821be5 | 35 | |
53a4677c | 36 | return '(do { ' |
37 | . 'my @potential = @{ (' . $slot_access . ') }; ' | |
38 | . '@return = splice @potential, $_[0], 1; ' | |
39 | . '\@potential; ' | |
40 | . '})'; | |
e32b7489 | 41 | } |
42 | ||
a486d5ad | 43 | sub _inline_optimized_set_new_value { |
53a4677c | 44 | my $self = shift; |
45 | my ($inv, $new, $slot_access) = @_; | |
e32b7489 | 46 | |
a486d5ad | 47 | return '@return = splice @{ (' . $slot_access . ') }, $_[0], 1;'; |
7f5ec80d | 48 | } |
49 | ||
50 | sub _return_value { | |
53a4677c | 51 | my $self = shift; |
52 | my ($slot_access) = @_; | |
7f5ec80d | 53 | |
53a4677c | 54 | return '$return[0]'; |
a7821be5 | 55 | } |
56 | ||
8b9641b8 | 57 | no Moose::Role; |
58 | ||
a7821be5 | 59 | 1; |