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