Use dzil Authority plugin - remove $AUTHORITY from code
[gitmo/Moose.git] / lib / Moose / Meta / Method / Accessor / Native / Array / reduce.pm
CommitLineData
910684ee 1package Moose::Meta::Method::Accessor::Native::Array::reduce;
2
3use strict;
4use warnings;
5
6use List::Util ();
88e88a7b 7use Params::Util ();
910684ee 8
8b9641b8 9use Moose::Role;
10
11with 'Moose::Meta::Method::Accessor::Native::Reader' => {
12 -excludes => [
13 qw(
14 _minimum_arguments
15 _maximum_arguments
16 _inline_check_arguments
17 )
18 ]
19};
910684ee 20
a7821be5 21sub _minimum_arguments { 1 }
22
23sub _maximum_arguments { 1 }
910684ee 24
25sub _inline_check_arguments {
e3181911 26 my $self = shift;
27
53a4677c 28 return (
29 'if (!Params::Util::_CODELIKE($_[0])) {',
30 $self->_inline_throw_error(
31 '"The argument passed to reduce must be a code reference"',
32 ) . ';',
33 '}',
34 );
910684ee 35}
36
37sub _return_value {
53a4677c 38 my $self = shift;
39 my ($slot_access) = @_;
910684ee 40
53a4677c 41 return 'List::Util::reduce { $_[0]->($a, $b) } @{ (' . $slot_access . ') }';
910684ee 42}
43
8b9641b8 44no Moose::Role;
45
910684ee 461;