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