1package MooseX::AttributeHelpers::MethodProvider::Bag; 2use Moose::Role; 3 4our $VERSION = '0.25'; 5 6with 'MooseX::AttributeHelpers::MethodProvider::ImmutableHash'; 7 8sub add : method { 9 my ($attr, $reader, $writer) = @_; 10 return sub { $reader->($_[0])->{$_[1]}++ }; 11} 12 13sub delete : method { 14 my ($attr, $reader, $writer) = @_; 15 return sub { CORE::delete $reader->($_[0])->{$_[1]} }; 16} 17 18sub reset : method { 19 my ($attr, $reader, $writer) = @_; 20 return sub { $reader->($_[0])->{$_[1]} = 0 }; 21} 22 231; 24 25__END__ 26 27=pod 28 29=encoding UTF-8 30 31=head1 NAME 32 33MooseX::AttributeHelpers::MethodProvider::Bag 34 35=head1 VERSION 36 37version 0.25 38 39=head1 DESCRIPTION 40 41This is a role which provides the method generators for 42L<MooseX::AttributeHelpers::Collection::Bag>. 43 44This role is composed from the 45L<MooseX::AttributeHelpers::Collection::ImmutableHash> role. 46 47=head1 METHODS 48 49=over 4 50 51=item B<meta> 52 53=back 54 55=head1 PROVIDED METHODS 56 57=over 4 58 59=item B<count> 60 61=item B<delete> 62 63=item B<empty> 64 65=item B<exists> 66 67=item B<get> 68 69=item B<keys> 70 71=item B<add> 72 73=item B<reset> 74 75=item B<values> 76 77=item B<kv> 78 79=back 80 81=head1 SUPPORT 82 83Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=MooseX-AttributeHelpers> 84(or L<bug-MooseX-AttributeHelpers@rt.cpan.org|mailto:bug-MooseX-AttributeHelpers@rt.cpan.org>). 85 86There is also a mailing list available for users of this distribution, at 87L<http://lists.perl.org/list/moose.html>. 88 89There is also an irc channel available for users of this distribution, at 90L<C<#moose> on C<irc.perl.org>|irc://irc.perl.org/#moose>. 91 92=head1 AUTHOR 93 94Stevan Little <stevan@iinteractive.com> 95 96=head1 COPYRIGHT AND LICENSE 97 98This software is copyright (c) 2007 by Stevan Little and Infinity Interactive, Inc. 99 100This is free software; you can redistribute it and/or modify it under 101the same terms as the Perl 5 programming language system itself. 102 103=cut 104