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