stop using excludes within moose, since it's no longer necessary
[gitmo/Moose.git] / lib / Moose / Meta / Method / Accessor / Native / Array / natatime.pm
CommitLineData
a7821be5 1package Moose::Meta::Method::Accessor::Native::Array::natatime;
2
3use strict;
4use warnings;
5
88e88a7b 6use List::MoreUtils ();
7use Params::Util ();
a7821be5 8
8b9641b8 9use Moose::Role;
10
00bbc132 11with 'Moose::Meta::Method::Accessor::Native::Reader';
a7821be5 12
1e2c801e 13sub _minimum_arguments { 1 }
a7821be5 14
1e2c801e 15sub _maximum_arguments { 2 }
a7821be5 16
17sub _inline_check_arguments {
18 my $self = shift;
19
53a4677c 20 return (
21 'if (!defined($_[0]) || $_[0] !~ /^\d+$/) {',
22 $self->_inline_throw_error(
23 '"The n value passed to natatime must be an integer"',
24 ) . ';',
25 '}',
26 'if (@_ == 2 && !Params::Util::_CODELIKE($_[1])) {',
27 $self->_inline_throw_error(
28 '"The second argument passed to natatime must be a code '
29 . 'reference"',
30 ) . ';',
31 '}',
32 );
a7821be5 33}
34
35sub _inline_return_value {
53a4677c 36 my $self = shift;
37 my ($slot_access) = @_;
38
39 return (
40 'my $iter = List::MoreUtils::natatime($_[0], @{ (' . $slot_access . ') });',
41 'if ($_[1]) {',
42 'while (my @vals = $iter->()) {',
43 '$_[1]->(@vals);',
44 '}',
45 '}',
46 'else {',
47 'return $iter;',
48 '}',
49 );
a7821be5 50}
51
8b9641b8 52# Not called, but needed to satisfy the Reader role
53sub _return_value { }
54
55no Moose::Role;
56
a7821be5 571;