2 package MooseX::AttributeHelpers::Counter;
4 use Moose::Util::TypeConstraints;
7 our $AUTHORITY = 'cpan:STEVAN';
9 extends 'MooseX::AttributeHelpers::Base';
11 sub helper_type { 'Num' }
13 has '+method_constructors' => (
18 return sub { $attr->set_value($_[0], $attr->get_value($_[0]) + 1) };
22 return sub { $attr->set_value($_[0], $attr->get_value($_[0]) - 1) };
29 no Moose::Util::TypeConstraints;
31 # register the alias ...
32 package Moose::Meta::Attribute::Custom::Counter;
33 sub register_implementation { 'MooseX::AttributeHelpers::Counter' }
43 MooseX::AttributeHelpers::Counter
51 metaclass => 'Counter',
60 my $page = MyHomePage->new();
61 $page->inc_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.