1 package MooseX::AttributeHelpers::Counter;
3 use MooseX::AttributeHelpers::MethodProvider::Counter;
5 extends 'MooseX::AttributeHelpers::Base';
8 our $AUTHORITY = 'cpan:STEVAN';
17 method_provider => 'Counter',
18 shortcut => 'Counter',
31 MooseX::AttributeHelpers::Counter
37 use MooseX::AttributeHelpers;
40 metaclass => 'Counter',
47 reset => 'reset_counter',
51 my $page = MyHomePage->new();
52 $page->inc_counter; # same as $page->counter($page->counter + 1);
53 $page->dec_counter; # same as $page->counter($page->counter - 1);
57 This module provides a simple counter attribute, which can be incremented and
58 decremented. It is important to note that all those methods do in place
59 modification of the value stored in the attribute.
61 If your attribute definition does not include any of I<is>, I<isa>,
62 I<default> or I<provides> but does use the C<Counter> metaclass,
63 then this module applies defaults as in the L</SYNOPSIS>
64 above. This allows for a very basic counter definition:
66 has 'foo' => (metaclass => 'Counter');
69 =head1 PROVIDED METHODS
71 The methods for this metaclass are provided by
72 L<MooseX::AttributeHelpers::MethodProvider::Counter>.
76 All complex software has bugs lurking in it, and this module is no
77 exception. If you find a bug please either email me, or add the bug
82 Stevan Little E<lt>stevan@iinteractive.comE<gt>
84 =head1 COPYRIGHT AND LICENSE
86 Copyright 2007-2008 by Infinity Interactive, Inc.
88 L<http://www.iinteractive.com>
90 This library is free software; you can redistribute it and/or modify
91 it under the same terms as Perl itself.