Checking in changes prior to tagging of version 0.93. Changelog diff is:
[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
6d0815b5 5our $VERSION = '0.93';
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
e22d28f2 48L<Moose::Meta::Attribute::Native::Trait::Counter>. Please check there for
7250a968 49documentation on what methods are provided.
e3c07b19 50
51=head1 METHODS
52
53=over 4
54
55=item B<meta>
56
57=back
58
e3c07b19 59=head1 BUGS
60
61All complex software has bugs lurking in it, and this module is no
62exception. If you find a bug please either email me, or add the bug
63to cpan-RT.
64
65=head1 AUTHOR
66
67Stevan Little E<lt>stevan@iinteractive.comE<gt>
68
69=head1 COPYRIGHT AND LICENSE
70
71Copyright 2007-2009 by Infinity Interactive, Inc.
72
73L<http://www.iinteractive.com>
74
75This library is free software; you can redistribute it and/or modify
76it under the same terms as Perl itself.
77
78=cut