2 package MooseX::AttributeHelpers::Counter;
6 $VERSION = eval $VERSION;
7 our $AUTHORITY = 'cpan:STEVAN';
9 extends 'Moose::Meta::Attribute';
10 with 'MooseX::AttributeHelpers::Trait::Counter';
14 # register the alias ...
15 package # hide me from search.cpan.org
16 Moose::Meta::Attribute::Custom::Counter;
17 sub register_implementation { 'MooseX::AttributeHelpers::Counter' }
27 MooseX::AttributeHelpers::Counter
33 use MooseX::AttributeHelpers;
36 metaclass => 'Counter',
43 reset => 'reset_counter',
47 my $page = MyHomePage->new();
48 $page->inc_counter; # same as $page->counter($page->counter + 1);
49 $page->dec_counter; # same as $page->counter($page->counter - 1);
53 This module provides a simple counter attribute, which can be
54 incremented and decremeneted.
56 If your attribute definition does not include any of I<is>, I<isa>,
57 I<default> or I<provides> but does use the C<Counter> metaclass,
58 then this module applies defaults as in the L</SYNOPSIS>
59 above. This allows for a very basic counter definition:
61 has 'foo' => (metaclass => 'Counter');
70 =item B<method_provider>
72 =item B<has_method_provider>
76 =item B<process_options_for_provides>
78 Run before its superclass method.
80 =item B<check_provides_values>
82 Run after its superclass method.
86 =head1 PROVIDED METHODS
88 It is important to note that all those methods do in place
89 modification of the value stored in the attribute.
95 Set the counter to the specified value.
99 Increments the value stored in this slot by 1. Providing an argument will
100 cause the counter to be increased by specified amount.
104 Decrements the value stored in this slot by 1. Providing an argument will
105 cause the counter to be increased by specified amount.
109 Resets the value stored in this slot to it's default value.
115 All complex software has bugs lurking in it, and this module is no
116 exception. If you find a bug please either email me, or add the bug
121 Stevan Little E<lt>stevan@iinteractive.comE<gt>
123 =head1 COPYRIGHT AND LICENSE
125 Copyright 2007-2008 by Infinity Interactive, Inc.
127 L<http://www.iinteractive.com>
129 This library is free software; you can redistribute it and/or modify
130 it under the same terms as Perl itself.