All unit tests passing with refactored stuff, documentation updated significantly.
[gitmo/MooseX-AttributeHelpers.git] / lib / MooseX / AttributeHelpers / MethodProvider / Bag.pm
CommitLineData
9a976497 1package MooseX::AttributeHelpers::MethodProvider::Bag;
2use Moose::Role;
3
4our $VERSION = '0.02';
5our $AUTHORITY = 'cpan:STEVAN';
6
7with 'MooseX::AttributeHelpers::MethodProvider::ImmutableHash';
8
9sub add : method {
10 my ($attr, $reader, $writer) = @_;
11 return sub { $reader->($_[0])->{$_[1]}++ };
12}
13
14sub delete : method {
15 my ($attr, $reader, $writer) = @_;
16 return sub { CORE::delete $reader->($_[0])->{$_[1]} };
17}
18
19sub reset : method {
20 my ($attr, $reader, $writer) = @_;
21 return sub { $reader->($_[0])->{$_[1]} = 0 };
22}
23
241;
25
26__END__
27
28=pod
29
30=head1 NAME
31
32MooseX::AttributeHelpers::MethodProvider::Bag
33
34=head1 DESCRIPTION
35
36This is a role which provides the method generators for
720fa35b 37L<MooseX::AttributeHelpers::Collection::Bag>. It also consumes
38L<MooseX::AttributeHelpers::Collection::ImmutableHash>, and thus provides all
39of its methods asw well.
9a976497 40
41=head1 PROVIDED METHODS
42
43=over 4
44
9a976497 45=item B<delete>
46
720fa35b 47Remove the supplied key from the bag.
9a976497 48
49=item B<add>
50
720fa35b 51Adds one to the value stored at the supplied key.
9a976497 52
720fa35b 53=item B<reset>
9a976497 54
720fa35b 55Sets the value at the supplied key to zero.
9a976497 56
57=back
58
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
99c62fb8 71Copyright 2007-2008 by Infinity Interactive, Inc.
9a976497 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
79