All unit tests passing with refactored stuff, documentation updated significantly.
[gitmo/MooseX-AttributeHelpers.git] / lib / MooseX / AttributeHelpers / MethodProvider / Counter.pm
1
2 package MooseX::AttributeHelpers::MethodProvider::Counter;
3 use Moose::Role;
4
5 our $VERSION   = '0.02';
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
13 sub inc {
14     my ($attr, $reader, $writer) = @_;
15     return sub { $writer->($_[0], $reader->($_[0]) + 1) };
16 }
17
18 sub dec {
19     my ($attr, $reader, $writer) = @_;
20     return sub { $writer->($_[0], $reader->($_[0]) - 1) };        
21 }
22
23 1;
24
25 __END__
26
27 =pod
28
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 PROVIDED METHODS
39
40 =over 4
41
42 =item I<inc>
43
44 Increments the value stored in this slot by 1.
45
46 =item I<dec>
47
48 Decrements the value stored in this slot by 1.
49
50 =item I<reset>
51
52 Resets the value stored in this slot to its default value.
53
54 =back
55
56 =head1 BUGS
57
58 All complex software has bugs lurking in it, and this module is no 
59 exception. If you find a bug please either email me, or add the bug
60 to cpan-RT.
61
62 =head1 AUTHOR
63
64 Stevan Little E<lt>stevan@iinteractive.comE<gt>
65
66 =head1 COPYRIGHT AND LICENSE
67
68 Copyright 2007-2008 by Infinity Interactive, Inc.
69
70 L<http://www.iinteractive.com>
71
72 This library is free software; you can redistribute it and/or modify
73 it under the same terms as Perl itself.
74
75 =cut