Version 0.17.
[gitmo/MooseX-AttributeHelpers.git] / lib / MooseX / AttributeHelpers / MethodProvider / Bag.pm
CommitLineData
9a976497 1package MooseX::AttributeHelpers::MethodProvider::Bag;
2use Moose::Role;
3
9e2db1c2 4our $VERSION = '0.17';
38430345 5$VERSION = eval $VERSION;
9a976497 6our $AUTHORITY = 'cpan:STEVAN';
7
8with 'MooseX::AttributeHelpers::MethodProvider::ImmutableHash';
9
10sub add : method {
11 my ($attr, $reader, $writer) = @_;
12 return sub { $reader->($_[0])->{$_[1]}++ };
13}
14
15sub delete : method {
16 my ($attr, $reader, $writer) = @_;
17 return sub { CORE::delete $reader->($_[0])->{$_[1]} };
18}
19
20sub reset : method {
21 my ($attr, $reader, $writer) = @_;
22 return sub { $reader->($_[0])->{$_[1]} = 0 };
23}
24
251;
26
27__END__
28
29=pod
30
31=head1 NAME
32
33MooseX::AttributeHelpers::MethodProvider::Bag
34
35=head1 DESCRIPTION
36
37This is a role which provides the method generators for
38L<MooseX::AttributeHelpers::Collection::Bag>.
39
40This role is composed from the
41L<MooseX::AttributeHelpers::Collection::ImmutableHash> role.
42
43=head1 METHODS
44
45=over 4
46
47=item B<meta>
48
49=back
50
51=head1 PROVIDED METHODS
52
53=over 4
54
55=item B<count>
56
57=item B<delete>
58
59=item B<empty>
60
61=item B<exists>
62
63=item B<get>
64
65=item B<keys>
66
67=item B<add>
68
69=item B<reset>
70
71=item B<values>
72
73=item B<kv>
74
75=back
76
77=head1 BUGS
78
79All complex software has bugs lurking in it, and this module is no
80exception. If you find a bug please either email me, or add the bug
81to cpan-RT.
82
83=head1 AUTHOR
84
85Stevan Little E<lt>stevan@iinteractive.comE<gt>
86
87=head1 COPYRIGHT AND LICENSE
88
99c62fb8 89Copyright 2007-2008 by Infinity Interactive, Inc.
9a976497 90
91L<http://www.iinteractive.com>
92
93This library is free software; you can redistribute it and/or modify
94it under the same terms as Perl itself.
95
96=cut
97