stop using excludes within moose, since it's no longer necessary
[gitmo/Moose.git] / lib / Moose / Meta / Method / Accessor / Native / Array / first_index.pm
1 package Moose::Meta::Method::Accessor::Native::Array::first_index;
2
3 use strict;
4 use warnings;
5
6 use List::MoreUtils ();
7 use Params::Util ();
8
9 use Moose::Role;
10
11 with 'Moose::Meta::Method::Accessor::Native::Reader';
12
13 sub _minimum_arguments { 1 }
14
15 sub _maximum_arguments { 1 }
16
17 sub _inline_check_arguments {
18     my $self = shift;
19
20     return (
21         'if (!Params::Util::_CODELIKE($_[0])) {',
22             $self->_inline_throw_error(
23                 '"The argument passed to first_index must be a code reference"',
24             ) . ';',
25         '}',
26     );
27 }
28
29 sub _return_value {
30     my $self = shift;
31     my ($slot_access) = @_;
32
33     return '&List::MoreUtils::first_index($_[0], @{ (' . $slot_access . ') })';
34 }
35
36 no Moose::Role;
37
38 1;