Use dzil Authority plugin - remove $AUTHORITY from code
[gitmo/Moose.git] / lib / Moose / Meta / Method / Accessor / Native / String / match.pm
1 package Moose::Meta::Method::Accessor::Native::String::match;
2
3 use strict;
4 use warnings;
5
6 use Moose::Util ();
7 use Params::Util ();
8
9 use Moose::Role;
10
11 with 'Moose::Meta::Method::Accessor::Native::Reader' => {
12     -excludes => [
13         qw(
14             _minimum_arguments
15             _maximum_arguments
16             _inline_check_arguments
17             )
18     ]
19 };
20
21 sub _minimum_arguments { 1 }
22
23 sub _maximum_arguments { 1 }
24
25 sub _inline_check_arguments {
26     my $self = shift;
27
28     return (
29         'if (!Moose::Util::_STRINGLIKE0($_[0]) && !Params::Util::_REGEX($_[0])) {',
30             $self->_inline_throw_error(
31                 '"The argument passed to match must be a string or regexp '
32               . 'reference"',
33             ) . ';',
34         '}',
35     );
36 }
37
38 sub _return_value {
39     my $self = shift;
40     my ($slot_access) = @_;
41
42     return $slot_access . ' =~ $_[0]';
43 }
44
45 no Moose::Role;
46
47 1;