Bump to 0.13
[gitmo/MooseX-AttributeHelpers.git] / lib / MooseX / AttributeHelpers.pm
index 691e9ae..225f3a8 100644 (file)
@@ -1,7 +1,7 @@
 
 package MooseX::AttributeHelpers;
 
-our $VERSION   = '0.09';
+our $VERSION   = '0.13';
 our $AUTHORITY = 'cpan:STEVAN';
 
 use MooseX::AttributeHelpers::Meta::Method::Provided;
@@ -45,10 +45,11 @@ MooseX::AttributeHelpers - Extend your attribute interfaces
           set       => 'set_mapping',
       },
       curries  => {
-          set       => [ set_quantity => 'quantity' ]
+          set       => { set_quantity => [ 'quantity' ] }
       }
   );
 
+
   # ...
 
   my $obj = MyClass->new;
@@ -57,6 +58,7 @@ MooseX::AttributeHelpers - Extend your attribute interfaces
   $obj->set_mapping(5, 'bar'); # 5 => 'bar'
   $obj->set_mapping(6, 'baz'); # 6 => 'baz'
 
+
   # prints 'bar'
   print $obj->get_mapping(5) if $obj->exists_in_mapping(5);
 
@@ -77,14 +79,36 @@ C<metaclass> parameter. Available meta classes are:
 =head2 provides
 
 This points to a hashref that uses C<provider> for the keys and
-C<['method', @args]> for the values.  The method will be added to
+C<method> for the values.  The method will be added to
 the object itself and do what you want.
 
 =head2 curries
 
 This points to a hashref that uses C<provider> for the keys and
-C<['method', @args]> for the values.  The method will be added to
-the object itself (always using C<@args> as the beginning arguments).
+has two choices for the value:
+
+You can supply C<< {method => [ @args ]} >> for the values.  The method will be
+added to the object itself (always using C<@args> as the beginning arguments).
+
+Another approach to curry a method provider is to supply a coderef instead of an
+arrayref. The code ref takes C<$self>, C<$body>, and any additional arguments
+passed to the final method.
+
+  # ...
+
+  curries => {
+      grep => {
+          times_with_day => sub {
+              my ($self, $body, $datetime) = @_;
+              $body->($self, sub { $_->ymd eq $datetime->ymd });
+          }
+      }
+  }
+
+  # ...
+
+  $obj->times_with_day(DateTime->now); # takes datetime argument, checks day
+
 
 =head1 METHOD PROVIDERS
 
@@ -98,7 +122,7 @@ Common numerical operations.
 
 Methods for incrementing and decrementing a counter attribute.
 
-=item L<Counter|MooseX::AttributeHelpers::Bool>
+=item L<Bool|MooseX::AttributeHelpers::Bool>
 
 Common methods for boolean values.
 
@@ -159,6 +183,8 @@ Yuval Kogman
 
 Jason May
 
+Cory (gphat) Watson
+
 =head1 COPYRIGHT AND LICENSE
 
 Copyright 2007, 2008 by Infinity Interactive, Inc.