diff options
author | doy <doy@tozt.net> | 2008-12-07 01:46:32 -0500 |
---|---|---|
committer | doy <doy@tozt.net> | 2008-12-07 01:46:32 -0500 |
commit | d28a13e435a68917535cd7948493480310869788 (patch) | |
tree | af7285275b4bc7e802ba213a8e9460c19cd29cd5 | |
parent | b2d38ce2f9a7728c473ee1def658e72147c5ef42 (diff) | |
download | moosex-role-matcher-d28a13e435a68917535cd7948493480310869788.tar.gz moosex-role-matcher-d28a13e435a68917535cd7948493480310869788.zip |
add examples to method docs
-rw-r--r-- | lib/MooseX/Role/Matcher.pm | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/MooseX/Role/Matcher.pm b/lib/MooseX/Role/Matcher.pm index 03cd03a..d621787 100644 --- a/lib/MooseX/Role/Matcher.pm +++ b/lib/MooseX/Role/Matcher.pm @@ -80,6 +80,8 @@ method _apply_to_matches => sub { =method first_match + my $four = Person->first_match([@people], sub { length == 4 }); + Class method which takes an arrayref of objects in the class that consumed this role, and calls C<match> on each object in the arrayref, passing it the remaining arguments, and returns the first object for which match returns true. @@ -93,6 +95,8 @@ method first_match => sub { =method grep_matches + my @not_twenty_two = Person->grep_matches([@people], '!age' => 22); + Class method which takes an arrayref of objects in the class that consumed this role, and calls C<match> on each object in the arrayref, passing it the remaining arguments, and returns the each object for which match returns true. @@ -107,6 +111,8 @@ method grep_matches => sub { =method any_match + Person->any_match([@people], age => 22, number => qr/4$/); + Class method which takes an arrayref of objects in the class that consumed this role, and calls C<match> on each object in the arrayref, passing it the remaining arguments, and returns true if any C<match> calls return true, @@ -121,6 +127,8 @@ method any_match => sub { =method all_match + Person->all_match([@people], name => [qr/^J/, qr/^E/]); + Class method which takes an arrayref of objects in the class that consumed this role, and calls C<match> on each object in the arrayref, passing it the remaining arguments, and returns false if any C<match> calls return false, @@ -155,6 +163,8 @@ method _match => sub { =method match + $person->match(age => 22); + This method provides the majority of the functionality of this role. It accepts a hash of arguments, with keys being the methods (usually attributes) of the object to be tested, and values being things to test against them. Possible |