Beginning of dzilization
[gitmo/Moose.git] / lib / Moose / Meta / Method / Accessor / Native / Hash / accessor.pm
1 package Moose::Meta::Method::Accessor::Native::Hash::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::Hash::set' => {
11     -excludes => [
12         qw(
13             _generate_method
14             _minimum_arguments
15             _maximum_arguments
16             _inline_check_arguments
17             _return_value
18             )
19     ]
20     },
21     'Moose::Meta::Method::Accessor::Native::Hash::get' => {
22     -excludes => [
23         qw(
24             _generate_method
25             _minimum_arguments
26             _maximum_arguments
27             _inline_check_argument_count
28             _inline_process_arguments
29             )
30     ]
31     };
32
33 sub _generate_method {
34     my $self = shift;
35
36     my $inv         = '$self';
37     my $slot_access = $self->_get_value($inv);
38
39     return (
40         'sub {',
41             'my ' . $inv . ' = shift;',
42             $self->_inline_curried_arguments,
43             $self->_inline_check_lazy($inv, '$type_constraint', '$type_constraint_obj'),
44             # get
45             'if (@_ == 1) {',
46                 $self->_inline_check_var_is_valid_key('$_[0]'),
47                 $self->Moose::Meta::Method::Accessor::Native::Hash::get::_inline_return_value($slot_access),
48             '}',
49             # set
50             'else {',
51                 $self->_inline_writer_core($inv, $slot_access),
52             '}',
53         '}',
54     );
55 }
56
57 sub _minimum_arguments { 1 }
58 sub _maximum_arguments { 2 }
59
60 no Moose::Role;
61
62 1;