Beginning of dzilization
[gitmo/Moose.git] / lib / Moose / Meta / Method / Accessor / Native / Array / reduce.pm
1 package Moose::Meta::Method::Accessor::Native::Array::reduce;
2
3 use strict;
4 use warnings;
5
6 use List::Util ();
7 use Params::Util ();
8
9 our $AUTHORITY = 'cpan:STEVAN';
10
11 use Moose::Role;
12
13 with 'Moose::Meta::Method::Accessor::Native::Reader' => {
14     -excludes => [
15         qw(
16             _minimum_arguments
17             _maximum_arguments
18             _inline_check_arguments
19             )
20     ]
21 };
22
23 sub _minimum_arguments { 1 }
24
25 sub _maximum_arguments { 1 }
26
27 sub _inline_check_arguments {
28     my $self = shift;
29
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     );
37 }
38
39 sub _return_value {
40     my $self = shift;
41     my ($slot_access) = @_;
42
43     return 'List::Util::reduce { $_[0]->($a, $b) } @{ (' . $slot_access . ') }';
44 }
45
46 no Moose::Role;
47
48 1;