7df4d9ea74b51b2fc47971cde18265a5e824b2f1
[gitmo/Moose.git] / lib / Moose / Meta / Method / Accessor / Native / Hash / get.pm
1 package Moose::Meta::Method::Accessor::Native::Hash::get;
2
3 use strict;
4 use warnings;
5
6 use Scalar::Util qw( looks_like_number );
7
8 use Moose::Role;
9
10 with 'Moose::Meta::Method::Accessor::Native::Reader',
11      'Moose::Meta::Method::Accessor::Native::Hash';
12
13 sub _minimum_arguments { 1 }
14
15 sub _inline_check_arguments {
16     my $self = shift;
17
18     return (
19         'for (@_) {',
20             $self->_inline_check_var_is_valid_key('$_'),
21         '}',
22     );
23 }
24
25 sub _return_value {
26     my $self = shift;
27     my ($slot_access) = @_;
28
29     return '@_ > 1 '
30              . '? @{ (' . $slot_access . ') }{@_} '
31              . ': ' . $slot_access . '->{$_[0]}';
32 }
33
34 no Moose::Role;
35
36 1;