2 package MooseX::AttributeHelpers::Collection::Bag;
4 use Moose::Util::TypeConstraints;
7 our $AUTHORITY = 'cpan:STEVAN';
9 use MooseX::AttributeHelpers::MethodProvider::Bag;
11 extends 'MooseX::AttributeHelpers::Collection';
13 has '+method_provider' => (
14 default => 'MooseX::AttributeHelpers::MethodProvider::Bag'
17 subtype 'Bag' => as 'HashRef[Int]';
19 sub helper_type { 'Bag' }
21 before 'process_options_for_provides' => sub {
22 my ($self, $options, $name) = @_;
24 # Set some default attribute options here unless already defined
25 if ((my $type = $self->helper_type) && !exists $options->{isa}){
26 $options->{isa} = $type;
29 $options->{default} = sub { +{} } unless exists $options->{default};
33 no Moose::Util::TypeConstraints;
35 # register the alias ...
36 package # hide me from search.cpan.org
37 Moose::Meta::Attribute::Custom::Collection::Bag;
38 sub register_implementation { 'MooseX::AttributeHelpers::Collection::Bag' }
48 MooseX::AttributeHelpers::Collection::Bag
54 use MooseX::AttributeHelpers;
56 has 'word_histogram' => (
57 metaclass => 'Collection::Bag',
59 isa => 'Bag', # optional ... as is defalt
62 'get' => 'get_count_for',
63 'empty' => 'has_any_words',
64 'count' => 'num_words',
65 'delete' => 'delete_word',
71 This module provides a Bag attribute which provides a number of
72 bag-like operations. See L<MooseX::AttributeHelpers::MethodProvider::Bag>
81 =item B<method_provider>
83 =item B<has_method_provider>
87 =item B<process_options_for_provides>
93 All complex software has bugs lurking in it, and this module is no
94 exception. If you find a bug please either email me, or add the bug
99 Stevan Little E<lt>stevan@iinteractive.comE<gt>
101 =head1 COPYRIGHT AND LICENSE
103 Copyright 2007 by Infinity Interactive, Inc.
105 L<http://www.iinteractive.com>
107 This library is free software; you can redistribute it and/or modify
108 it under the same terms as Perl itself.