make github the primary repository
[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
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 (!Moose::Util::_STRINGLIKE0($_[0]) && !Params::Util::_REGEX($_[0])) {',
22             $self->_inline_throw_error(
23                 '"The argument passed to match must be a string or regexp '
24               . 'reference"',
25             ) . ';',
26         '}',
27     );
28 }
29
30 sub _return_value {
31     my $self = shift;
32     my ($slot_access) = @_;
33
34     return $slot_access . ' =~ $_[0]';
35 }
36
37 no Moose::Role;
38
39 1;