1 package Moose::Meta::Method::Accessor::Native::Array::set;
7 $VERSION = eval $VERSION;
8 our $AUTHORITY = 'cpan:STEVAN';
12 with 'Moose::Meta::Method::Accessor::Native::Array::Writer' => {
17 _inline_check_arguments
19 _inline_optimized_set_new_value
25 sub _minimum_arguments { 2 }
27 sub _maximum_arguments { 2 }
29 sub _inline_check_arguments {
32 return $self->_inline_check_var_is_valid_index('$_[0]');
35 sub _adds_members { 1 }
37 sub _potential_value {
38 my ( $self, $slot_access ) = @_;
41 "( do { my \@potential = \@{ ($slot_access) }; \$potential[ \$_[0] ] = \$_[1]; \\\@potential } )";
44 # We need to override this because while @_ can be written to, we cannot write
46 around _inline_coerce_new_values => sub {
50 return q{} unless $self->associated_attribute->should_coerce;
52 return q{} unless $self->_tc_member_type_can_coerce;
54 return '@_ = ( $_[0], $member_tc_obj->coerce( $_[1] ) );';
57 sub _new_members { '$_[1]' }
59 sub _inline_optimized_set_new_value {
60 my ( $self, $inv, $new, $slot_access ) = @_;
62 return "${slot_access}->[ \$_[0] ] = \$_[1]";
66 my ( $self, $slot_access ) = @_;
68 return "return ${slot_access}->[ \$_[0] ];";