Never use die in generate code when throwing an error.
[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
6our $VERSION = '1.13';
7$VERSION = eval $VERSION;
8our $AUTHORITY = 'cpan:STEVAN';
9
10use base 'Moose::Meta::Method::Accessor::Native::Array::Reader';
11
a7821be5 12sub _minimum_arguments { 1 }
13
14sub _maximum_arguments { 1 }
910684ee 15
16sub _inline_check_arguments {
e3181911 17 my $self = shift;
18
19 return $self->_inline_throw_error(
20 q{'The argument passed to grep must be a code reference'})
21 . q{if $_[0] && ( ref $_[0] || q{} ) ne 'CODE';};
910684ee 22}
23
24sub _return_value {
25 my $self = shift;
26 my $slot_access = shift;
27
a7821be5 28 return "grep { \$_[0]->() } \@{ $slot_access }";
910684ee 29}
30
311;