Beginning of dzilization
[gitmo/Moose.git] / lib / Moose / Meta / Method / Accessor / Native / Array / accessor.pm
1 package Moose::Meta::Method::Accessor::Native::Array::accessor;
2
3 use strict;
4 use warnings;
5
6 our $AUTHORITY = 'cpan:STEVAN';
7
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     };
29
30 sub _generate_method {
31     my $self = shift;
32
33     my $inv         = '$self';
34     my $slot_access = $self->_get_value($inv);
35
36     return (
37         'sub {',
38             'my ' . $inv . ' = shift;',
39             $self->_inline_curried_arguments,
40             $self->_inline_check_lazy($inv, '$type_constraint', '$type_constraint_obj'),
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 {',
48                 $self->_inline_writer_core($inv, $slot_access),
49             '}',
50         '}',
51     );
52 }
53
54 sub _minimum_arguments { 1 }
55 sub _maximum_arguments { 2 }
56
57 no Moose::Role;
58
59 1;