Commit | Line | Data |
---|---|---|
a7821be5 | 1 | package Moose::Meta::Method::Accessor::Native::Array::delete; |
2 | ||
3 | use strict; | |
4 | use warnings; | |
5 | ||
245478d5 | 6 | our $VERSION = '1.19'; |
a7821be5 | 7 | $VERSION = eval $VERSION; |
8 | our $AUTHORITY = 'cpan:STEVAN'; | |
9 | ||
8b9641b8 | 10 | use Moose::Role; |
11 | ||
12 | with 'Moose::Meta::Method::Accessor::Native::Array::Writer' => { | |
13 | -excludes => [ | |
14 | qw( | |
15 | _minimum_arguments | |
16 | _maximum_arguments | |
17 | _inline_check_arguments | |
53a4677c | 18 | _optimized_set_new_value |
7f5ec80d | 19 | _return_value |
8b9641b8 | 20 | ) |
21 | ], | |
22 | }; | |
a7821be5 | 23 | |
24 | sub _minimum_arguments { 1 } | |
25 | ||
26 | sub _maximum_arguments { 1 } | |
27 | ||
28 | sub _inline_check_arguments { | |
29 | my $self = shift; | |
30 | ||
31 | return $self->_inline_check_var_is_valid_index('$_[0]'); | |
32 | } | |
33 | ||
34 | sub _adds_members { 0 } | |
35 | ||
36 | sub _potential_value { | |
53a4677c | 37 | my $self = shift; |
38 | my ($slot_access) = @_; | |
a7821be5 | 39 | |
53a4677c | 40 | return '(do { ' |
41 | . 'my @potential = @{ (' . $slot_access . ') }; ' | |
42 | . '@return = splice @potential, $_[0], 1; ' | |
43 | . '\@potential; ' | |
44 | . '})'; | |
e32b7489 | 45 | } |
46 | ||
53a4677c | 47 | sub _optimized_set_new_value { |
48 | my $self = shift; | |
49 | my ($inv, $new, $slot_access) = @_; | |
e32b7489 | 50 | |
53a4677c | 51 | return '@return = splice @{ (' . $slot_access . ') }, $_[0], 1'; |
7f5ec80d | 52 | } |
53 | ||
54 | sub _return_value { | |
53a4677c | 55 | my $self = shift; |
56 | my ($slot_access) = @_; | |
7f5ec80d | 57 | |
53a4677c | 58 | return '$return[0]'; |
a7821be5 | 59 | } |
60 | ||
8b9641b8 | 61 | no Moose::Role; |
62 | ||
a7821be5 | 63 | 1; |