1 package Moose::Meta::Method::Accessor::Native::Array::insert;
7 $VERSION = eval $VERSION;
8 our $AUTHORITY = 'cpan:STEVAN';
12 with 'Moose::Meta::Method::Accessor::Native::Array::Writer' => {
18 _inline_optimized_set_new_value
24 sub _minimum_arguments { 2 }
26 sub _maximum_arguments { 2 }
28 sub _adds_members { 1 }
30 sub _potential_value {
31 my ( $self, $slot_access ) = @_;
34 "( do { my \@potential = \@{ ($slot_access) }; splice \@potential, \$_[0], 0, \$_[1]; \\\@potential } )";
37 # We need to override this because while @_ can be written to, we cannot write
39 around _inline_coerce_new_values => sub {
43 return q{} unless $self->associated_attribute->should_coerce;
45 return q{} unless $self->_tc_member_type_can_coerce;
47 return '@_ = ( $_[0], $member_tc_obj->coerce( $_[1] ) );';
50 sub _new_members { '$_[1]' }
52 sub _inline_optimized_set_new_value {
53 my ( $self, $inv, $new, $slot_access ) = @_;
55 return "splice \@{ ($slot_access) }, \$_[0], 0, \$_[1];";
59 my ( $self, $slot_access ) = @_;
61 return "return ${slot_access}->[ \$_[0] ];";