if we aren't calling _inline_return_value, none of this is necessary
[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
8b9641b8 6use Moose::Role;
7
8with 'Moose::Meta::Method::Accessor::Native::Hash::set' => {
9 -excludes => [
10 qw(
11 _generate_method
12 _minimum_arguments
13 _maximum_arguments
8b9641b8 14 )
15 ]
16 },
17 'Moose::Meta::Method::Accessor::Native::Hash::get' => {
18 -excludes => [
19 qw(
20 _generate_method
21 _minimum_arguments
22 _maximum_arguments
23 _inline_check_argument_count
30423145 24 _inline_check_arguments
8b9641b8 25 _inline_process_arguments
30423145 26 _return_value
8b9641b8 27 )
28 ]
29 };
44babf1f 30
31sub _generate_method {
32 my $self = shift;
33
53a4677c 34 my $inv = '$self';
1e2c801e 35 my $slot_access = $self->_get_value($inv);
44babf1f 36
53a4677c 37 return (
38 'sub {',
53a4677c 39 'my ' . $inv . ' = shift;',
40 $self->_inline_curried_arguments,
a619fc2f 41 $self->_inline_check_lazy($inv, '$type_constraint', '$type_coercion', '$type_message'),
53a4677c 42 # get
43 'if (@_ == 1) {',
44 $self->_inline_check_var_is_valid_key('$_[0]'),
178c5d84 45 $slot_access . '->{$_[0]}',
53a4677c 46 '}',
47 # set
48 'else {',
1e2c801e 49 $self->_inline_writer_core($inv, $slot_access),
53a4677c 50 '}',
51 '}',
52 );
44babf1f 53}
54
1e2c801e 55sub _minimum_arguments { 1 }
56sub _maximum_arguments { 2 }
44babf1f 57
8b9641b8 58no Moose::Role;
44babf1f 59
601;