1 package Moose::Meta::Method::Accessor::Native::Array;
7 use Scalar::Util qw( looks_like_number );
10 $VERSION = eval $VERSION;
11 our $AUTHORITY = 'cpan:STEVAN';
13 use base 'Moose::Meta::Method::Accessor::Native';
15 sub _inline_curried_arguments {
18 return q{} unless @{ $self->curried_arguments };
20 return 'unshift @_, @curried;'
23 sub _inline_check_argument_count {
28 if ( my $min = $self->_minimum_arguments ) {
29 my $err_msg = sprintf(
30 q{"Cannot call %s without at least %s argument%s"},
31 $self->delegate_to_method,
33 ( $min == 1 ? q{} : 's' )
38 . $self->_inline_throw_error($err_msg)
39 . " unless \@_ >= $min;";
42 if ( defined( my $max = $self->_maximum_arguments ) ) {
43 my $err_msg = sprintf(
44 q{"Cannot call %s with %s argument%s"},
45 $self->delegate_to_method,
46 ( $max ? "more than $max" : 'any' ),
47 ( $max == 1 ? q{} : 's' )
52 . $self->_inline_throw_error($err_msg)
59 sub _minimum_arguments { 0 }
60 sub _maximum_arguments { undef }
62 sub _inline_check_arguments { q{} }
64 sub _inline_check_var_is_valid_index {
65 my ( $self, $var ) = @_;
67 return $self->_inline_throw_error( q{'The index passed to }
68 . $self->delegate_to_method
69 . q{ must be an integer'} )
70 . qq{ unless defined $var && $var =~ /^-?\\d+\$/;};