Commit | Line | Data |
44babf1f |
1 | package Moose::Meta::Method::Accessor::Native::Hash::accessor; |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
bb8ef151 |
6 | our $VERSION = '1.9900'; |
44babf1f |
7 | $VERSION = eval $VERSION; |
8 | our $AUTHORITY = 'cpan:STEVAN'; |
9 | |
8b9641b8 |
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 | }; |
44babf1f |
34 | |
35 | sub _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, |
ec86bdff |
45 | $self->_inline_check_lazy($inv, '$type_constraint', '$type_constraint_obj'), |
53a4677c |
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 |
59 | sub _minimum_arguments { 1 } |
60 | sub _maximum_arguments { 2 } |
44babf1f |
61 | |
8b9641b8 |
62 | no Moose::Role; |
44babf1f |
63 | |
64 | 1; |