make github the primary repository
[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
8b9641b8 9use Moose::Role;
10
00bbc132 11with 'Moose::Meta::Method::Accessor::Native::Reader';
f7fd22b6 12
a7821be5 13sub _minimum_arguments { 1 }
14
15sub _maximum_arguments { 1 }
f5f08b5f 16
910684ee 17sub _inline_check_arguments {
e3181911 18 my $self = shift;
19
53a4677c 20 return (
21 'if (!Params::Util::_CODELIKE($_[0])) {',
22 $self->_inline_throw_error(
23 '"The argument passed to first must be a code reference"',
24 ) . ';',
25 '}',
26 );
910684ee 27}
28
f7fd22b6 29sub _return_value {
53a4677c 30 my $self = shift;
31 my ($slot_access) = @_;
f7fd22b6 32
1e2c801e 33 return '&List::Util::first($_[0], @{ (' . $slot_access . ') })';
f7fd22b6 34}
35
8b9641b8 36no Moose::Role;
37
f7fd22b6 381;