Version 0.96.
[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
2e7576bd 5our $VERSION = '0.96';
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
8b09d5c3 43Moose::Meta::Attribute::Native::MethodProvider::Counter - role providing method generators for Counter trait
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
d4048ef3 61See L<Moose/BUGS> for details on reporting bugs.
e3c07b19 62
63=head1 AUTHOR
64
65Stevan Little E<lt>stevan@iinteractive.comE<gt>
66
67=head1 COPYRIGHT AND LICENSE
68
69Copyright 2007-2009 by Infinity Interactive, Inc.
70
71L<http://www.iinteractive.com>
72
73This library is free software; you can redistribute it and/or modify
74it under the same terms as Perl itself.
75
76=cut