mass renaming, including removing MethodProviders from the Trait namespace
[gitmo/Moose.git] / lib / Moose / Meta / Attribute / Native / MethodProvider / Counter.pm
CommitLineData
e3c07b19 1
c466e58f 2package Moose::Meta::Attribute::Native::MethodProvider::Counter;
e3c07b19 3use Moose::Role;
4
96539d20 5our $VERSION = '0.87';
e3c07b19 6$VERSION = eval $VERSION;
7our $AUTHORITY = 'cpan:STEVAN';
8
9sub reset : method {
046c8b5e 10 my ( $attr, $reader, $writer ) = @_;
11 return sub { $writer->( $_[0], $attr->default( $_[0] ) ) };
e3c07b19 12}
13
14sub set : method {
046c8b5e 15 my ( $attr, $reader, $writer, $value ) = @_;
16 return sub { $writer->( $_[0], $_[1] ) };
e3c07b19 17}
18
19sub inc {
046c8b5e 20 my ( $attr, $reader, $writer ) = @_;
21 return sub {
22 $writer->( $_[0],
23 $reader->( $_[0] ) + ( defined( $_[1] ) ? $_[1] : 1 ) );
24 };
e3c07b19 25}
26
27sub dec {
046c8b5e 28 my ( $attr, $reader, $writer ) = @_;
29 return sub {
30 $writer->( $_[0],
31 $reader->( $_[0] ) - ( defined( $_[1] ) ? $_[1] : 1 ) );
32 };
e3c07b19 33}
34
351;
36
37__END__
38
39=pod
40
41=head1 NAME
42
c466e58f 43Moose::Meta::Attribute::Native::MethodProvider::Counter
e3c07b19 44
45=head1 DESCRIPTION
46
47This is a role which provides the method generators for
a40b446a 48L<Moose::Meta::Attribute::Trait::Native::Counter>.
e3c07b19 49
50=head1 METHODS
51
52=over 4
53
54=item B<meta>
55
56=back
57
58=head1 PROVIDED METHODS
59
60=over 4
61
62=item B<set>
63
64=item B<inc>
65
66=item B<dec>
67
68=item B<reset>
69
70=back
71
72=head1 BUGS
73
74All complex software has bugs lurking in it, and this module is no
75exception. If you find a bug please either email me, or add the bug
76to cpan-RT.
77
78=head1 AUTHOR
79
80Stevan Little E<lt>stevan@iinteractive.comE<gt>
81
82=head1 COPYRIGHT AND LICENSE
83
84Copyright 2007-2009 by Infinity Interactive, Inc.
85
86L<http://www.iinteractive.com>
87
88This library is free software; you can redistribute it and/or modify
89it under the same terms as Perl itself.
90
91=cut