more cleanups
[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 $VERSION = '1.19';
7 $VERSION = eval $VERSION;
8 our $AUTHORITY = 'cpan:STEVAN';
9
10 use Moose::Role;
11
12 with 'Moose::Meta::Method::Accessor::Native::Hash::set' => {
13     -excludes => [
14         qw(
15             _generate_method
16             _minimum_arguments
17             _maximum_arguments
18             _inline_check_arguments
19             _return_value
20             )
21     ]
22     },
23     'Moose::Meta::Method::Accessor::Native::Hash::get' => {
24     -excludes => [
25         qw(
26             _generate_method
27             _minimum_arguments
28             _maximum_arguments
29             _inline_check_argument_count
30             _inline_process_arguments
31             )
32     ]
33     };
34
35 sub _generate_method {
36     my $self = shift;
37
38     my $inv         = '$self';
39     my $slot_access = $self->_get_value($inv);
40
41     return (
42         'sub {',
43             $self->_inline_pre_body(@_),
44             'my ' . $inv . ' = shift;',
45             $self->_inline_curried_arguments,
46             $self->_inline_check_lazy($inv),
47             # get
48             'if (@_ == 1) {',
49                 $self->_inline_check_var_is_valid_key('$_[0]'),
50                 $self->Moose::Meta::Method::Accessor::Native::Hash::get::_inline_return_value($slot_access),
51             '}',
52             # set
53             'else {',
54                 $self->_inline_writer_core($inv, $slot_access),
55                 $self->_inline_post_body(@_),
56             '}',
57         '}',
58     );
59 }
60
61 sub _minimum_arguments { 1 }
62 sub _maximum_arguments { 2 }
63
64 no Moose::Role;
65
66 1;