Commit | Line | Data |
8e3fab6d |
1 | |
2 | package MooseX::AttributeHelpers::MethodProvider::Counter; |
3 | use Moose::Role; |
4 | |
c91a1347 |
5 | our $VERSION = '0.02'; |
457dc4fb |
6 | our $AUTHORITY = 'cpan:STEVAN'; |
7 | |
8 | sub reset : method { |
9 | my ($attr, $reader, $writer) = @_; |
10 | return sub { $writer->($_[0], $attr->default($_[0])) }; |
11 | } |
12 | |
8e3fab6d |
13 | sub inc { |
457dc4fb |
14 | my ($attr, $reader, $writer) = @_; |
15 | return sub { $writer->($_[0], $reader->($_[0]) + 1) }; |
8e3fab6d |
16 | } |
17 | |
18 | sub dec { |
457dc4fb |
19 | my ($attr, $reader, $writer) = @_; |
20 | return sub { $writer->($_[0], $reader->($_[0]) - 1) }; |
8e3fab6d |
21 | } |
22 | |
23 | 1; |
24 | |
25 | __END__ |
26 | |
27 | =pod |
28 | |
5431dff2 |
29 | =head1 NAME |
30 | |
31 | MooseX::AttributeHelpers::MethodProvider::Counter |
32 | |
33 | =head1 DESCRIPTION |
34 | |
35 | This is a role which provides the method generators for |
36 | L<MooseX::AttributeHelpers::Counter>. |
37 | |
38 | =head1 METHODS |
39 | |
40 | =over 4 |
41 | |
42 | =item B<meta> |
43 | |
44 | =back |
45 | |
46 | =head1 PROVIDED METHODS |
47 | |
48 | =over 4 |
49 | |
50 | =item B<inc> |
51 | |
52 | =item B<dec> |
53 | |
457dc4fb |
54 | =item B<reset> |
55 | |
5431dff2 |
56 | =back |
57 | |
58 | =head1 BUGS |
59 | |
60 | All complex software has bugs lurking in it, and this module is no |
61 | exception. If you find a bug please either email me, or add the bug |
62 | to cpan-RT. |
63 | |
64 | =head1 AUTHOR |
65 | |
66 | Stevan Little E<lt>stevan@iinteractive.comE<gt> |
67 | |
68 | =head1 COPYRIGHT AND LICENSE |
69 | |
99c62fb8 |
70 | Copyright 2007-2008 by Infinity Interactive, Inc. |
5431dff2 |
71 | |
72 | L<http://www.iinteractive.com> |
73 | |
74 | This library is free software; you can redistribute it and/or modify |
75 | it under the same terms as Perl itself. |
76 | |
77 | =cut |