18b971ccfbcfae3de2b0cff97b8beb4f4e9a7102
[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 our $VERSION = '1.9900';
9 $VERSION = eval $VERSION;
10 our $AUTHORITY = 'cpan:STEVAN';
11
12 use Moose::Role;
13
14 with 'Moose::Meta::Method::Accessor::Native::Reader' => {
15     -excludes => [
16         qw(
17             _minimum_arguments
18             _maximum_arguments
19             _inline_check_arguments
20             )
21     ]
22 };
23
24 sub _minimum_arguments { 1 }
25
26 sub _maximum_arguments { 1 }
27
28 sub _inline_check_arguments {
29     my $self = shift;
30
31     return (
32         'if (!Params::Util::_CODELIKE($_[0])) {',
33             $self->_inline_throw_error(
34                 '"The argument passed to grep must be a code reference"',
35             ) . ';',
36         '}',
37     );
38 }
39
40 sub _return_value {
41     my $self = shift;
42     my ($slot_access) = @_;
43
44     return 'grep { $_[0]->() } @{ (' . $slot_access . ') }';
45 }
46
47 no Moose::Role;
48
49 1;