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