Add a deprecatoin warning
[gitmo/MooseX-AttributeHelpers.git] / lib / MooseX / AttributeHelpers.pm
index 691e9ae..488b648 100644 (file)
@@ -1,12 +1,25 @@
 
 package MooseX::AttributeHelpers;
 
-our $VERSION   = '0.09';
+our $VERSION   = '0.23';
+$VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
+use Moose 0.56 ();
+
 use MooseX::AttributeHelpers::Meta::Method::Provided;
 use MooseX::AttributeHelpers::Meta::Method::Curried;
 
+use MooseX::AttributeHelpers::Trait::Bool;
+use MooseX::AttributeHelpers::Trait::Counter;
+use MooseX::AttributeHelpers::Trait::Number;
+use MooseX::AttributeHelpers::Trait::String;
+use MooseX::AttributeHelpers::Trait::Collection::List;
+use MooseX::AttributeHelpers::Trait::Collection::Array;
+use MooseX::AttributeHelpers::Trait::Collection::Hash;
+use MooseX::AttributeHelpers::Trait::Collection::ImmutableHash;
+use MooseX::AttributeHelpers::Trait::Collection::Bag;
+
 use MooseX::AttributeHelpers::Counter;
 use MooseX::AttributeHelpers::Number;
 use MooseX::AttributeHelpers::String;
@@ -25,7 +38,7 @@ __END__
 
 =head1 NAME
 
-MooseX::AttributeHelpers - Extend your attribute interfaces
+MooseX::AttributeHelpers - Extend your attribute interfaces (deprecated)
 
 =head1 SYNOPSIS
 
@@ -45,10 +58,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 +71,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);
 
@@ -65,6 +80,10 @@ MooseX::AttributeHelpers - Extend your attribute interfaces
 
 =head1 DESCRIPTION
 
+B<This distribution is deprecated. The features it provides have been added to
+the Moose core code as L<Moose::Meta::Attribute::Native>. This distribution
+should not be used by any new code.>
+
 While L<Moose> attributes provide you with a way to name your accessors,
 readers, writers, clearers and predicates, this library provides commonly
 used attribute helper methods for more specific types of data.
@@ -77,14 +96,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
 
@@ -94,11 +135,15 @@ the object itself (always using C<@args> as the beginning arguments).
 
 Common numerical operations.
 
+=item L<String|MooseX::AttributeHelpers::String>
+
+Common methods for string operations.
+
 =item L<Counter|MooseX::AttributeHelpers::Counter>
 
 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.
 
@@ -106,6 +151,10 @@ Common methods for boolean values.
 
 Common methods for hash references.
 
+=item L<Collection::ImmutableHash|MooseX::AttributeHelpers::Collection::ImmutableHash>
+
+Common methods for inspecting hash references.
+
 =item L<Collection::Array|MooseX::AttributeHelpers::Collection::Array>
 
 Common methods for array references.
@@ -159,9 +208,17 @@ Yuval Kogman
 
 Jason May
 
+Cory (gphat) Watson
+
+Florian (rafl) Ragwitz
+
+Evan Carroll
+
+Jesse (doy) Luehrs
+
 =head1 COPYRIGHT AND LICENSE
 
-Copyright 2007, 2008 by Infinity Interactive, Inc.
+Copyright 2007-2009 by Infinity Interactive, Inc.
 
 L<http://www.iinteractive.com>