give credit in Changes
[gitmo/Moose.git] / lib / Moose / Meta / Method / Accessor / Native / Array / set.pm
CommitLineData
a7821be5 1package Moose::Meta::Method::Accessor::Native::Array::set;
2
3use strict;
4use warnings;
5
bb09ad91 6our $VERSION = '1.17';
a7821be5 7$VERSION = eval $VERSION;
8our $AUTHORITY = 'cpan:STEVAN';
9
8b9641b8 10use Moose::Role;
11
12with 'Moose::Meta::Method::Accessor::Native::Array::Writer' => {
13 -excludes => [
14 qw(
15 _minimum_arguments
16 _maximum_arguments
17 _inline_check_arguments
18 _new_members
19 _inline_optimized_set_new_value
7f5ec80d 20 _return_value
8b9641b8 21 )
22 ]
23};
a7821be5 24
25sub _minimum_arguments { 2 }
26
27sub _maximum_arguments { 2 }
28
29sub _inline_check_arguments {
30 my $self = shift;
31
32 return $self->_inline_check_var_is_valid_index('$_[0]');
33}
34
35sub _adds_members { 1 }
36
37sub _potential_value {
38 my ( $self, $slot_access ) = @_;
39
40 return
1d06edbf 41 "( do { my \@potential = \@{ ($slot_access) }; \$potential[ \$_[0] ] = \$_[1]; \\\@potential } )";
a7821be5 42}
43
44babf1f 44sub _new_members { '$_[1]' }
a7821be5 45
e32b7489 46sub _inline_optimized_set_new_value {
47 my ( $self, $inv, $new, $slot_access ) = @_;
48
584540d9 49 return "${slot_access}->[ \$_[0] ] = \$_[1]";
e32b7489 50}
51
7f5ec80d 52sub _return_value {
53 my ( $self, $slot_access ) = @_;
54
55 return "return ${slot_access}->[ \$_[0] ];";
56}
57
8b9641b8 58no Moose::Role;
59
a7821be5 601;