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