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