X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMooseX%2FAttributeHelpers%2FMethodProvider%2FCounter.pm;h=8a9b09db71c665e5ed73e1e515440c67699aebf8;hb=99c62fb8cb5b5da1d5832062364ce48e1dd15800;hp=ca85b049a74eeb3b8d1679ec4d8a95fe73bfe52f;hpb=8e3fab6d99875597bfae0e77329ec7516a7ff5df;p=gitmo%2FMooseX-AttributeHelpers.git diff --git a/lib/MooseX/AttributeHelpers/MethodProvider/Counter.pm b/lib/MooseX/AttributeHelpers/MethodProvider/Counter.pm index ca85b04..8a9b09d 100644 --- a/lib/MooseX/AttributeHelpers/MethodProvider/Counter.pm +++ b/lib/MooseX/AttributeHelpers/MethodProvider/Counter.pm @@ -2,14 +2,22 @@ package MooseX::AttributeHelpers::MethodProvider::Counter; use Moose::Role; +our $VERSION = '0.02'; +our $AUTHORITY = 'cpan:STEVAN'; + +sub reset : method { + my ($attr, $reader, $writer) = @_; + return sub { $writer->($_[0], $attr->default($_[0])) }; +} + sub inc { - my $attr = shift; - return sub { $attr->set_value($_[0], $attr->get_value($_[0]) + 1) }; + my ($attr, $reader, $writer) = @_; + return sub { $writer->($_[0], $reader->($_[0]) + 1) }; } sub dec { - my $attr = shift; - return sub { $attr->set_value($_[0], $attr->get_value($_[0]) - 1) }; + my ($attr, $reader, $writer) = @_; + return sub { $writer->($_[0], $reader->($_[0]) - 1) }; } 1; @@ -18,4 +26,52 @@ __END__ =pod -=cut \ No newline at end of file +=head1 NAME + +MooseX::AttributeHelpers::MethodProvider::Counter + +=head1 DESCRIPTION + +This is a role which provides the method generators for +L. + +=head1 METHODS + +=over 4 + +=item B + +=back + +=head1 PROVIDED METHODS + +=over 4 + +=item B + +=item B + +=item B + +=back + +=head1 BUGS + +All complex software has bugs lurking in it, and this module is no +exception. If you find a bug please either email me, or add the bug +to cpan-RT. + +=head1 AUTHOR + +Stevan Little Estevan@iinteractive.comE + +=head1 COPYRIGHT AND LICENSE + +Copyright 2007-2008 by Infinity Interactive, Inc. + +L + +This library is free software; you can redistribute it and/or modify +it under the same terms as Perl itself. + +=cut