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