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