1 package MooseX::AttributeHelpers::MethodProvider::Collection::Bag;
2 use MooseX::AttributeHelpers::MethodProvider;
3 use MooseX::AttributeHelpers::MethodProvider::Collection::ImmutableHash;
4 use Moose::Util::TypeConstraints;
7 our $AUTHORITY = 'cpan:STEVAN';
9 subtype 'Bag' => as 'HashRef[Int]';
11 add_method_provider 'Collection::Bag' => (
13 consumes => { 'Collection::ImmutableHash' => ':all' },
16 my ($attr, $reader, $writer) = @_;
17 return sub { $reader->($_[0])->{$_[1]}++ };
21 my ($attr, $reader, $writer) = @_;
22 return sub { CORE::delete $reader->($_[0])->{$_[1]} };
26 my ($attr, $reader, $writer) = @_;
27 return sub { $reader->($_[0])->{$_[1]} = 0 };
40 MooseX::AttributeHelpers::MethodProvider::Bag
44 This is a role which provides the method generators for
45 L<MooseX::AttributeHelpers::Collection::Bag>. It also consumes
46 L<MooseX::AttributeHelpers::Collection::ImmutableHash>, and thus provides all
47 of its methods asw well.
49 =head1 PROVIDED METHODS
55 Remove the supplied key from the bag.
59 Adds one to the value stored at the supplied key.
63 Sets the value at the supplied key to zero.
69 All complex software has bugs lurking in it, and this module is no
70 exception. If you find a bug please either email me, or add the bug
75 Stevan Little E<lt>stevan@iinteractive.comE<gt>
77 =head1 COPYRIGHT AND LICENSE
79 Copyright 2007-2008 by Infinity Interactive, Inc.
81 L<http://www.iinteractive.com>
83 This library is free software; you can redistribute it and/or modify
84 it under the same terms as Perl itself.