2 package MooseX::AttributeHelpers::Counter;
6 our $AUTHORITY = 'cpan:STEVAN';
8 extends 'MooseX::AttributeHelpers::Base';
10 sub helper_type { 'Num' }
12 has '+method_constructors' => (
17 return sub { $attr->set_value($_[0], $attr->get_value($_[0]) + 1) };
21 return sub { $attr->set_value($_[0], $attr->get_value($_[0]) - 1) };
29 # register the alias ...
30 package Moose::Meta::Attribute::Custom::Counter;
31 sub register_implementation { 'MooseX::AttributeHelpers::Counter' }
41 MooseX::AttributeHelpers::Counter
49 metaclass => 'Counter',
59 my $page = MyHomePage->new();
60 $page->inc_counter; # same as $page->counter($page->counter + 1);
61 $page->dec_counter; # same as $page->counter($page->counter - 1);
69 All complex software has bugs lurking in it, and this module is no
70 exception. If you find a bug please either email me, or add the bug
75 Stevan Little E<lt>stevan@iinteractive.comE<gt>
77 =head1 COPYRIGHT AND LICENSE
79 Copyright 2007 by Infinity Interactive, Inc.
81 L<http://www.iinteractive.com>
83 This library is free software; you can redistribute it and/or modify
84 it under the same terms as Perl itself.