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