Merge branch 'master' into traits
[gitmo/MooseX-AttributeHelpers.git] / lib / MooseX / AttributeHelpers / Counter.pm
index 32bc897..9a2cea2 100644 (file)
@@ -2,41 +2,18 @@
 package MooseX::AttributeHelpers::Counter;
 use Moose;
 
-our $VERSION   = '0.01';
+our $VERSION   = '0.17';
+$VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
-use MooseX::AttributeHelpers::MethodProvider::Counter;
-
-extends 'MooseX::AttributeHelpers::Base';
-
-has '+method_provider' => (
-    default => 'MooseX::AttributeHelpers::MethodProvider::Counter'
-);
-
-sub helper_type { 'Num' }
-
-before 'process_options_for_provides' => sub {
-    my ($self, $options, $name) = @_;
-
-    # Set some default attribute options here unless already defined
-    if (my $type = $self->helper_type and not exists $options->{isa}){
-        $options->{isa} = $self->helper_type;
-    }
-    $options->{is} = 'ro' unless exists $options->{is};
-    $options->{default} = 0 unless exists $options->{default};
-    
-    # If no provides are specified we'll default to all of them
-    unless ( exists $options->{provides} and
-             grep { exists $options->{provides}{$_} } qw( inc dec reset )
-    ){
-        @{$options->{provides}}{qw(inc dec reset)} = ("inc_$name", "dec_$name", "reset_$name");
-    }
-};
+extends 'Moose::Meta::Attribute';
+with 'MooseX::AttributeHelpers::Trait::Counter';
 
 no Moose;
 
 # register the alias ...
-package Moose::Meta::Attribute::Custom::Counter;
+package # hide me from search.cpan.org
+    Moose::Meta::Attribute::Custom::Counter;
 sub register_implementation { 'MooseX::AttributeHelpers::Counter' }
 
 1;
@@ -88,6 +65,8 @@ above. This allows for a very basic counter definition:
 
 =over 4
 
+=item B<meta>
+
 =item B<method_provider>
 
 =item B<has_method_provider>
@@ -98,6 +77,10 @@ above. This allows for a very basic counter definition:
 
 Run before its superclass method.
 
+=item B<check_provides_values>
+
+Run after its superclass method.
+
 =back
 
 =head1 PROVIDED METHODS
@@ -107,17 +90,23 @@ modification of the value stored in the attribute.
 
 =over 4
 
+=item I<set>
+
+Set the counter to the specified value.
+
 =item I<inc>
 
-Increments the value stored in this slot by 1.
+Increments the value stored in this slot by 1. Providing an argument will
+cause the counter to be increased by specified amount.
 
 =item I<dec>
 
-Decrements the value stored in this slot by 1.
+Decrements the value stored in this slot by 1. Providing an argument will
+cause the counter to be increased by specified amount.
 
 =item I<reset>
 
-Resets the value stored in this slot to it's default value.
+Resets the value stored in this slot to it's default value. 
 
 =back
 
@@ -133,7 +122,7 @@ Stevan Little E<lt>stevan@iinteractive.comE<gt>
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright 2007 by Infinity Interactive, Inc.
+Copyright 2007-2008 by Infinity Interactive, Inc.
 
 L<http://www.iinteractive.com>