2 package MooseX::AttributeHelpers::Counter;
6 our $AUTHORITY = 'cpan:STEVAN';
8 extends 'Moose::Meta::Attribute';
9 with 'MooseX::AttributeHelpers::Trait::Counter';
13 # register the alias ...
14 package # hide me from search.cpan.org
15 Moose::Meta::Attribute::Custom::Counter;
16 sub register_implementation { 'MooseX::AttributeHelpers::Counter' }
26 MooseX::AttributeHelpers::Counter
32 use MooseX::AttributeHelpers;
35 metaclass => 'Counter',
42 reset => 'reset_counter',
46 my $page = MyHomePage->new();
47 $page->inc_counter; # same as $page->counter($page->counter + 1);
48 $page->dec_counter; # same as $page->counter($page->counter - 1);
52 This module provides a simple counter attribute, which can be
53 incremented and decremeneted.
55 If your attribute definition does not include any of I<is>, I<isa>,
56 I<default> or I<provides> but does use the C<Counter> metaclass,
57 then this module applies defaults as in the L</SYNOPSIS>
58 above. This allows for a very basic counter definition:
60 has 'foo' => (metaclass => 'Counter');
69 =item B<method_provider>
71 =item B<has_method_provider>
75 =item B<process_options_for_provides>
77 Run before its superclass method.
79 =item B<check_provides_values>
81 Run after its superclass method.
85 =head1 PROVIDED METHODS
87 It is important to note that all those methods do in place
88 modification of the value stored in the attribute.
94 Increments the value stored in this slot by 1.
98 Decrements the value stored in this slot by 1.
102 Resets the value stored in this slot to it's default value.
108 All complex software has bugs lurking in it, and this module is no
109 exception. If you find a bug please either email me, or add the bug
114 Stevan Little E<lt>stevan@iinteractive.comE<gt>
116 =head1 COPYRIGHT AND LICENSE
118 Copyright 2007-2008 by Infinity Interactive, Inc.
120 L<http://www.iinteractive.com>
122 This library is free software; you can redistribute it and/or modify
123 it under the same terms as Perl itself.