2 package MooseX::AttributeHelpers::Counter;
4 use MooseX::AttributeHelpers::Sugar;
6 extends 'MooseX::AttributeHelpers::Base';
9 our $AUTHORITY = 'cpan:STEVAN';
11 define_attribute_helper (
18 method_provider => 'MooseX::AttributeHelpers::MethodProvider::Counter',
20 shortcut => 'Counter',
24 no MooseX::AttributeHelpers::Sugar;
34 MooseX::AttributeHelpers::Counter
40 use MooseX::AttributeHelpers;
43 metaclass => 'Counter',
50 reset => 'reset_counter',
54 my $page = MyHomePage->new();
55 $page->inc_counter; # same as $page->counter($page->counter + 1);
56 $page->dec_counter; # same as $page->counter($page->counter - 1);
60 This module provides a simple counter attribute, which can be
61 incremented and decremeneted.
63 If your attribute definition does not include any of I<is>, I<isa>,
64 I<default> or I<provides> but does use the C<Counter> metaclass,
65 then this module applies defaults as in the L</SYNOPSIS>
66 above. This allows for a very basic counter definition:
68 has 'foo' => (metaclass => 'Counter');
77 =head1 PROVIDED METHODS
79 It is important to note that all those methods do in place
80 modification of the value stored in the attribute.
86 Increments the value stored in this slot by 1.
90 Decrements the value stored in this slot by 1.
94 Resets the value stored in this slot to it's default value.
100 All complex software has bugs lurking in it, and this module is no
101 exception. If you find a bug please either email me, or add the bug
106 Stevan Little E<lt>stevan@iinteractive.comE<gt>
108 =head1 COPYRIGHT AND LICENSE
110 Copyright 2007-2008 by Infinity Interactive, Inc.
112 L<http://www.iinteractive.com>
114 This library is free software; you can redistribute it and/or modify
115 it under the same terms as Perl itself.