From d28a13e435a68917535cd7948493480310869788 Mon Sep 17 00:00:00 2001 From: doy Date: Sun, 7 Dec 2008 01:46:32 -0500 Subject: add examples to method docs --- lib/MooseX/Role/Matcher.pm | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 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 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 on each object in the arrayref, passing it the remaining arguments, and returns true if any C 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 on each object in the arrayref, passing it the remaining arguments, and returns false if any C 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 -- cgit v1.2.3-54-g00ecf