bump version to 1.15
[gitmo/Moose.git] / lib / Moose / Meta / Method / Accessor / Native / Array / splice.pm
CommitLineData
a7821be5 1package Moose::Meta::Method::Accessor::Native::Array::splice;
2
3use strict;
4use warnings;
5
efa728b4 6our $VERSION = '1.15';
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 _inline_process_arguments
17 _inline_check_arguments
18 _inline_optimized_set_new_value
19 )
20 ]
21};
a7821be5 22
23sub _minimum_arguments { 1 }
24
25sub _adds_members { 1 }
26
27sub _inline_process_arguments {
28 return 'my $idx = shift;' . "\n" . 'my $len = @_ ? shift : undef;';
29}
30
31sub _inline_check_arguments {
32 my $self = shift;
33
e3181911 34 return
35 $self->_inline_check_var_is_valid_index('$idx') . "\n"
36 . $self->_inline_throw_error(q{'The length argument passed to splice must be an integer'})
37 . ' if defined $len && $len !~ /^-?\\d+$/;';
a7821be5 38}
39
40sub _potential_value {
41 my ( $self, $slot_access ) = @_;
42
43 return "( do { my \@potential = \@{ $slot_access };"
e32b7489 44 . 'defined $len ? ( splice @potential, $idx, $len, @_ ) : ( splice @potential, $idx ); \\@potential } )';
45}
46
47sub _inline_optimized_set_new_value {
48 my ( $self, $inv, $new, $slot_access ) = @_;
49
584540d9 50 return "defined \$len ? ( splice \@{ $slot_access }, \$idx, \$len, \@_ ) : ( splice \@{ $slot_access }, \$idx )";
a7821be5 51}
52
8b9641b8 53no Moose::Role;
54
a7821be5 551;