Allow overloading on arguments to native trait methods
[gitmo/Moose.git] / lib / Moose / Meta / Method / Accessor / Native / Array / first.pm
1 package Moose::Meta::Method::Accessor::Native::Array::first;
2
3 use strict;
4 use warnings;
5
6 use List::Util ();
7 use Params::Util ();
8
9 our $VERSION = '1.14';
10 $VERSION = eval $VERSION;
11 our $AUTHORITY = 'cpan:STEVAN';
12
13 use Moose::Role;
14
15 with 'Moose::Meta::Method::Accessor::Native::Reader' => {
16     -excludes => [
17         qw(
18             _minimum_arguments
19             _maximum_arguments
20             _inline_check_arguments
21             )
22     ]
23 };
24
25 sub _minimum_arguments { 1 }
26
27 sub _maximum_arguments { 1 }
28
29 sub _inline_check_arguments {
30     my $self = shift;
31
32     return $self->_inline_throw_error(
33         q{'The argument passed to first must be a code reference'})
34         . q{ unless Params::Util::_CODELIKE( $_[0] );};
35 }
36
37 sub _return_value {
38     my $self        = shift;
39     my $slot_access = shift;
40
41     return "&List::Util::first( \$_[0], \@{ ${slot_access} } )";
42 }
43
44 no Moose::Role;
45
46 1;