Commit | Line | Data |
---|---|---|
f7fd22b6 | 1 | package Moose::Meta::Method::Accessor::Native::Array::map; |
2 | ||
3 | use strict; | |
4 | use warnings; | |
5 | ||
88e88a7b | 6 | use Params::Util (); |
7 | ||
8b9641b8 | 8 | use Moose::Role; |
9 | ||
00bbc132 | 10 | with 'Moose::Meta::Method::Accessor::Native::Reader'; |
f7fd22b6 | 11 | |
a7821be5 | 12 | sub _minimum_arguments { 1 } |
13 | ||
14 | sub _maximum_arguments { 1 } | |
f7fd22b6 | 15 | |
910684ee | 16 | sub _inline_check_arguments { |
e3181911 | 17 | my $self = shift; |
18 | ||
53a4677c | 19 | return ( |
20 | 'if (!Params::Util::_CODELIKE($_[0])) {', | |
21 | $self->_inline_throw_error( | |
22 | '"The argument passed to map must be a code reference"', | |
23 | ) . ';', | |
24 | '}', | |
25 | ); | |
910684ee | 26 | } |
27 | ||
f7fd22b6 | 28 | sub _return_value { |
53a4677c | 29 | my $self = shift; |
30 | my ($slot_access) = @_; | |
f7fd22b6 | 31 | |
53a4677c | 32 | return 'map { $_[0]->() } @{ (' . $slot_access . ') }'; |
f7fd22b6 | 33 | } |
34 | ||
8b9641b8 | 35 | no Moose::Role; |
36 | ||
f7fd22b6 | 37 | 1; |