Beginning of dzilization
[gitmo/Moose.git] / lib / Moose / Meta / Method / Accessor / Native / Array / first.pm
CommitLineData
f7fd22b6 1package Moose::Meta::Method::Accessor::Native::Array::first;
2
3use strict;
4use warnings;
5
f5f08b5f 6use List::Util ();
88e88a7b 7use Params::Util ();
f5f08b5f 8
f7fd22b6 9our $AUTHORITY = 'cpan:STEVAN';
10
8b9641b8 11use Moose::Role;
12
13with 'Moose::Meta::Method::Accessor::Native::Reader' => {
14 -excludes => [
15 qw(
16 _minimum_arguments
17 _maximum_arguments
18 _inline_check_arguments
19 )
20 ]
21};
f7fd22b6 22
a7821be5 23sub _minimum_arguments { 1 }
24
25sub _maximum_arguments { 1 }
f5f08b5f 26
910684ee 27sub _inline_check_arguments {
e3181911 28 my $self = shift;
29
53a4677c 30 return (
31 'if (!Params::Util::_CODELIKE($_[0])) {',
32 $self->_inline_throw_error(
33 '"The argument passed to first must be a code reference"',
34 ) . ';',
35 '}',
36 );
910684ee 37}
38
f7fd22b6 39sub _return_value {
53a4677c 40 my $self = shift;
41 my ($slot_access) = @_;
f7fd22b6 42
1e2c801e 43 return '&List::Util::first($_[0], @{ (' . $slot_access . ') })';
f7fd22b6 44}
45
8b9641b8 46no Moose::Role;
47
f7fd22b6 481;