1 package Moose::Meta::Method::Accessor::Native::Array::natatime;
6 use List::MoreUtils ();
10 $VERSION = eval $VERSION;
11 our $AUTHORITY = 'cpan:STEVAN';
15 with 'Moose::Meta::Method::Accessor::Native::Reader' => {
20 _inline_check_arguments
26 sub _minimum_arguments {1}
28 sub _maximum_arguments {2}
30 sub _inline_check_arguments {
33 return $self->_inline_throw_error(
34 q{'The n value passed to natatime must be an integer'})
35 . ' unless defined $_[0] && $_[0] =~ /^\\d+$/;' . "\n"
36 . $self->_inline_throw_error(
37 q{'The second argument passed to natatime must be a code reference'})
38 . q{ if @_ == 2 && ! Params::Util::_CODELIKE( $_[1] );};
41 sub _inline_return_value {
42 my ( $self, $slot_access ) = @_;
45 "my \$iter = List::MoreUtils::natatime( \$_[0], \@{ ($slot_access) } );"
47 . 'if ( $_[1] ) {' . "\n"
48 . 'while (my @vals = $iter->()) {' . "\n"
49 . '$_[1]->(@vals);' . "\n" . '}' . "\n"
51 . 'return $iter;' . "\n" . '}';
54 # Not called, but needed to satisfy the Reader role