make native trait inlining work
[gitmo/Moose.git] / lib / Moose / Meta / Method / Accessor / Native / Array.pm
1 package Moose::Meta::Method::Accessor::Native::Array;
2
3 use strict;
4 use warnings;
5
6 use Moose::Role;
7
8 use Scalar::Util qw( looks_like_number );
9
10 our $VERSION = '1.19';
11 $VERSION = eval $VERSION;
12 our $AUTHORITY = 'cpan:STEVAN';
13
14 sub _inline_check_var_is_valid_index {
15     my $self = shift;
16     my ($var) = @_;
17
18     return (
19         'if (!defined(' . $var . ') || ' . $var . ' !~ /^-?\d+$/) {',
20             $self->_inline_throw_error(
21                 '"The index passed to '
22               . $self->delegate_to_method
23               . ' must be an integer"',
24             ) . ';',
25         '}',
26     );
27 }
28
29 no Moose::Role;
30
31 1;