Commit | Line | Data |
44babf1f |
1 | package Moose::Meta::Method::Accessor::Native::Hash::accessor; |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
8b9641b8 |
6 | use Moose::Role; |
7 | |
00bbc132 |
8 | with 'Moose::Meta::Method::Accessor::Native::Hash::set', |
9 | 'Moose::Meta::Method::Accessor::Native::Hash::get'; |
10 | |
11 | sub _inline_process_arguments { |
12 | my $self = shift; |
13 | $self->Moose::Meta::Method::Accessor::Native::Hash::set::_inline_process_arguments(@_); |
14 | } |
15 | |
16 | sub _inline_check_argument_count { |
17 | my $self = shift; |
18 | $self->Moose::Meta::Method::Accessor::Native::Hash::set::_inline_check_argument_count(@_); |
19 | } |
20 | |
21 | sub _inline_check_arguments { |
22 | my $self = shift; |
23 | $self->Moose::Meta::Method::Accessor::Native::Hash::set::_inline_check_arguments(@_); |
24 | } |
25 | |
26 | sub _return_value { |
27 | my $self = shift; |
28 | $self->Moose::Meta::Method::Accessor::Native::Hash::set::_return_value(@_); |
29 | } |
44babf1f |
30 | |
31 | sub _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 |
55 | sub _minimum_arguments { 1 } |
56 | sub _maximum_arguments { 2 } |
44babf1f |
57 | |
8b9641b8 |
58 | no Moose::Role; |
44babf1f |
59 | |
60 | 1; |