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