Composite now implemented.
[gitmo/MooseX-AttributeHelpers.git] / lib / MooseX / AttributeHelpers / Counter.pm
index 32bc897..eaabe06 100644 (file)
@@ -1,43 +1,24 @@
-
 package MooseX::AttributeHelpers::Counter;
 use Moose;
-
-our $VERSION   = '0.01';
-our $AUTHORITY = 'cpan:STEVAN';
-
 use MooseX::AttributeHelpers::MethodProvider::Counter;
 
 extends 'MooseX::AttributeHelpers::Base';
 
-has '+method_provider' => (
-    default => 'MooseX::AttributeHelpers::MethodProvider::Counter'
-);
+our $VERSION   = '0.03';
+our $AUTHORITY = 'cpan:STEVAN';
 
-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");
-    }
-};
+__PACKAGE__->sugar(
+    default_options  => {
+        is      => 'ro', 
+        default => 0,
+    },
 
-no Moose;
+    auto_provide     => 1,
+    method_provider  => 'Counter',
+    shortcut         => 'Counter',
+);
 
-# register the alias ...
-package Moose::Meta::Attribute::Custom::Counter;
-sub register_implementation { 'MooseX::AttributeHelpers::Counter' }
+no Moose;
 
 1;
 
@@ -73,8 +54,9 @@ MooseX::AttributeHelpers::Counter
   
 =head1 DESCRIPTION
 
-This module provides a simple counter attribute, which can be 
-incremented and decremeneted. 
+This module provides a simple counter attribute, which can be incremented and 
+decremented.  It is important to note that all those methods do in place 
+modification of the value stored in the attribute.
 
 If your attribute definition does not include any of I<is>, I<isa>,
 I<default> or I<provides> but does use the C<Counter> metaclass,
@@ -84,42 +66,10 @@ above. This allows for a very basic counter definition:
   has 'foo' => (metaclass => 'Counter');
   $obj->inc_foo;
 
-=head1 METHODS
-
-=over 4
-
-=item B<method_provider>
-
-=item B<has_method_provider>
-
-=item B<helper_type>
-
-=item B<process_options_for_provides>
-
-Run before its superclass method.
-
-=back
-
 =head1 PROVIDED METHODS
 
-It is important to note that all those methods do in place
-modification of the value stored in the attribute.
-
-=over 4
-
-=item I<inc>
-
-Increments the value stored in this slot by 1.
-
-=item I<dec>
-
-Decrements the value stored in this slot by 1.
-
-=item I<reset>
-
-Resets the value stored in this slot to it's default value.
-
-=back
+The methods for this metaclass are provided by
+L<MooseX::AttributeHelpers::MethodProvider::Counter>.
 
 =head1 BUGS
 
@@ -133,7 +83,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>