Commit | Line | Data |
a7821be5 |
1 | package Moose::Meta::Method::Accessor::Native::Array::accessor; |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
a7821be5 |
6 | our $AUTHORITY = 'cpan:STEVAN'; |
7 | |
8b9641b8 |
8 | use Moose::Role; |
9 | |
10 | with 'Moose::Meta::Method::Accessor::Native::Array::set' => { |
11 | -excludes => [ |
12 | qw( _generate_method |
13 | _minimum_arguments |
14 | _maximum_arguments |
15 | _inline_process_arguments |
16 | _inline_check_arguments |
17 | _return_value) |
18 | ] |
19 | }, |
20 | 'Moose::Meta::Method::Accessor::Native::Array::get' => { |
21 | -excludes => [ |
22 | qw( |
23 | _generate_method |
24 | _minimum_arguments |
25 | _maximum_arguments |
26 | ) |
27 | ] |
28 | }; |
a7821be5 |
29 | |
30 | sub _generate_method { |
31 | my $self = shift; |
32 | |
53a4677c |
33 | my $inv = '$self'; |
1e2c801e |
34 | my $slot_access = $self->_get_value($inv); |
a7821be5 |
35 | |
53a4677c |
36 | return ( |
37 | 'sub {', |
53a4677c |
38 | 'my ' . $inv . ' = shift;', |
39 | $self->_inline_curried_arguments, |
ec86bdff |
40 | $self->_inline_check_lazy($inv, '$type_constraint', '$type_constraint_obj'), |
53a4677c |
41 | # get |
42 | 'if (@_ == 1) {', |
43 | $self->_inline_check_var_is_valid_index('$_[0]'), |
44 | $self->Moose::Meta::Method::Accessor::Native::Array::get::_inline_return_value($slot_access), |
45 | '}', |
46 | # set |
47 | 'else {', |
1e2c801e |
48 | $self->_inline_writer_core($inv, $slot_access), |
53a4677c |
49 | '}', |
50 | '}', |
51 | ); |
a7821be5 |
52 | } |
53 | |
1e2c801e |
54 | sub _minimum_arguments { 1 } |
55 | sub _maximum_arguments { 2 } |
a7821be5 |
56 | |
8b9641b8 |
57 | no Moose::Role; |
a7821be5 |
58 | |
59 | 1; |