2 package MooseX::AttributeHelpers::Trait::Collection::Bag;
4 use Moose::Util::TypeConstraints;
7 our $AUTHORITY = 'cpan:STEVAN';
9 use MooseX::AttributeHelpers::MethodProvider::Bag;
11 with 'MooseX::AttributeHelpers::Trait::Collection';
13 has 'method_provider' => (
16 predicate => 'has_method_provider',
17 default => 'MooseX::AttributeHelpers::MethodProvider::Bag'
20 subtype 'Bag' => as 'HashRef[Int]';
22 sub helper_type { 'Bag' }
24 before 'process_options_for_provides' => sub {
25 my ($self, $options, $name) = @_;
27 # Set some default attribute options here unless already defined
28 if ((my $type = $self->helper_type) && !exists $options->{isa}){
29 $options->{isa} = $type;
32 $options->{default} = sub { +{} } unless exists $options->{default};
36 no Moose::Util::TypeConstraints;
38 # register the alias ...
39 package # hide me from search.cpan.org
40 Moose::Meta::Attribute::Custom::Trait::Collection::Bag;
41 sub register_implementation {
42 'MooseX::AttributeHelpers::Trait::Collection::Bag'
53 MooseX::AttributeHelpers::Collection::Bag
59 use MooseX::AttributeHelpers;
61 has 'word_histogram' => (
62 metaclass => 'Collection::Bag',
64 isa => 'Bag', # optional ... as is defalt
67 'get' => 'get_count_for',
68 'empty' => 'has_any_words',
69 'count' => 'num_words',
70 'delete' => 'delete_word',
76 This module provides a Bag attribute which provides a number of
77 bag-like operations. See L<MooseX::AttributeHelpers::MethodProvider::Bag>
86 =item B<method_provider>
88 =item B<has_method_provider>
92 =item B<process_options_for_provides>
98 All complex software has bugs lurking in it, and this module is no
99 exception. If you find a bug please either email me, or add the bug
104 Stevan Little E<lt>stevan@iinteractive.comE<gt>
106 =head1 COPYRIGHT AND LICENSE
108 Copyright 2007-2008 by Infinity Interactive, Inc.
110 L<http://www.iinteractive.com>
112 This library is free software; you can redistribute it and/or modify
113 it under the same terms as Perl itself.