diff options
author | doy <doy@tozt.net> | 2008-12-06 20:21:08 -0500 |
---|---|---|
committer | doy <doy@tozt.net> | 2008-12-06 20:21:08 -0500 |
commit | e72c5fd3a95e3babb5d4b30523c10b7678a0631d (patch) | |
tree | 2239f77415f519a6daec596fe3380668d8ecd702 | |
parent | ceb871336eec2484357a60c06bfc9cd68e00a0ce (diff) | |
download | moosex-role-matcher-e72c5fd3a95e3babb5d4b30523c10b7678a0631d.tar.gz moosex-role-matcher-e72c5fd3a95e3babb5d4b30523c10b7678a0631d.zip |
make the list matchers into class methods, rather than normal subs
-rw-r--r-- | lib/MooseX/Role/Matcher.pm | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/MooseX/Role/Matcher.pm b/lib/MooseX/Role/Matcher.pm index d39e388..767bb1f 100644 --- a/lib/MooseX/Role/Matcher.pm +++ b/lib/MooseX/Role/Matcher.pm @@ -14,6 +14,7 @@ my $p = shift; my $default = $p->default_match; method _apply_to_matches => sub { + my $class = shift; my $on_match = shift; my $matcher = shift; my @list = @{ shift() }; @@ -22,20 +23,25 @@ method _apply_to_matches => sub { }; method first_match => sub { - _apply_to_matches(\&first, sub { $_->match(@_) }, @_); + my $class = shift; + $class->_apply_to_matches(\&first, sub { $_->match(@_) }, @_); }; method each_match => sub { - _apply_to_matches(\&apply, shift, @_); + my $class = shift; + my $code = shift; + $class->_apply_to_matches(\&apply, $code, @_); }; method grep_matches => sub { + my $class = shift; # XXX: can you use grep like this? - _apply_to_matches(\&grep, sub { $_->match(@_) }, @_); + $class->_apply_to_matches(\&grep, sub { $_->match(@_) }, @_); }; method any_match => sub { - _apply_to_matches(\&any, sub { $_->match(@_) }, @_); + my $class = shift; + $class->_apply_to_matches(\&any, sub { $_->match(@_) }, @_); }; method _match => sub { |