stop using excludes within moose, since it's no longer necessary
[gitmo/Moose.git] / lib / Moose / Meta / Method / Accessor / Native / Array / grep.pm
1 package Moose::Meta::Method::Accessor::Native::Array::grep;
2
3 use strict;
4 use warnings;
5
6 use Params::Util ();
7
8 use Moose::Role;
9
10 with 'Moose::Meta::Method::Accessor::Native::Reader';
11
12 sub _minimum_arguments { 1 }
13
14 sub _maximum_arguments { 1 }
15
16 sub _inline_check_arguments {
17     my $self = shift;
18
19     return (
20         'if (!Params::Util::_CODELIKE($_[0])) {',
21             $self->_inline_throw_error(
22                 '"The argument passed to grep must be a code reference"',
23             ) . ';',
24         '}',
25     );
26 }
27
28 sub _return_value {
29     my $self = shift;
30     my ($slot_access) = @_;
31
32     return 'grep { $_[0]->() } @{ (' . $slot_access . ') }';
33 }
34
35 no Moose::Role;
36
37 1;