From e72c5fd3a95e3babb5d4b30523c10b7678a0631d Mon Sep 17 00:00:00 2001 From: doy Date: Sat, 6 Dec 2008 20:21:08 -0500 Subject: make the list matchers into class methods, rather than normal subs --- lib/MooseX/Role/Matcher.pm | 14 ++++++++++---- 1 file 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 { -- cgit v1.2.3-54-g00ecf