push the accessor inlining code back into the attribute
[gitmo/Moose.git] / lib / Moose / Meta / Method / Accessor / Native / Hash / accessor.pm
CommitLineData
44babf1f 1package Moose::Meta::Method::Accessor::Native::Hash::accessor;
2
3use strict;
4use warnings;
5
245478d5 6our $VERSION = '1.19';
44babf1f 7$VERSION = eval $VERSION;
8our $AUTHORITY = 'cpan:STEVAN';
9
8b9641b8 10use Moose::Role;
11
12with '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 };
44babf1f 34
35sub _generate_method {
36 my $self = shift;
37
53a4677c 38 my $inv = '$self';
1e2c801e 39 my $slot_access = $self->_get_value($inv);
44babf1f 40
53a4677c 41 return (
42 'sub {',
53a4677c 43 'my ' . $inv . ' = shift;',
44 $self->_inline_curried_arguments,
45 $self->_inline_check_lazy($inv),
46 # get
47 'if (@_ == 1) {',
48 $self->_inline_check_var_is_valid_key('$_[0]'),
49 $self->Moose::Meta::Method::Accessor::Native::Hash::get::_inline_return_value($slot_access),
50 '}',
51 # set
52 'else {',
1e2c801e 53 $self->_inline_writer_core($inv, $slot_access),
53a4677c 54 '}',
55 '}',
56 );
44babf1f 57}
58
1e2c801e 59sub _minimum_arguments { 1 }
60sub _maximum_arguments { 2 }
44babf1f 61
8b9641b8 62no Moose::Role;
44babf1f 63
641;