2 package MooseX::AttributeHelpers::Trait::Collection::Bag;
4 use Moose::Util::TypeConstraints;
7 $VERSION = eval $VERSION;
8 our $AUTHORITY = 'cpan:STEVAN';
10 use MooseX::AttributeHelpers::MethodProvider::Bag;
12 with 'MooseX::AttributeHelpers::Trait::Collection';
14 has 'method_provider' => (
17 predicate => 'has_method_provider',
18 default => 'MooseX::AttributeHelpers::MethodProvider::Bag'
21 subtype 'Bag' => as 'HashRef[Int]';
23 sub helper_type { 'Bag' }
25 before 'process_options_for_provides' => sub {
26 my ($self, $options, $name) = @_;
28 # Set some default attribute options here unless already defined
29 if ((my $type = $self->helper_type) && !exists $options->{isa}){
30 $options->{isa} = $type;
33 $options->{default} = sub { +{} } unless exists $options->{default};
37 no Moose::Util::TypeConstraints;
47 MooseX::AttributeHelpers::Collection::Bag
53 use MooseX::AttributeHelpers;
55 has 'word_histogram' => (
56 metaclass => 'Collection::Bag',
58 isa => 'Bag', # optional ... as is defalt
61 'get' => 'get_count_for',
62 'empty' => 'has_any_words',
63 'count' => 'num_words',
64 'delete' => 'delete_word',
70 This module provides a Bag attribute which provides a number of
71 bag-like operations. See L<MooseX::AttributeHelpers::MethodProvider::Bag>
80 =item B<method_provider>
82 =item B<has_method_provider>
86 =item B<process_options_for_provides>
92 All complex software has bugs lurking in it, and this module is no
93 exception. If you find a bug please either email me, or add the bug
98 Stevan Little E<lt>stevan@iinteractive.comE<gt>
100 =head1 COPYRIGHT AND LICENSE
102 Copyright 2007-2009 by Infinity Interactive, Inc.
104 L<http://www.iinteractive.com>
106 This library is free software; you can redistribute it and/or modify
107 it under the same terms as Perl itself.