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]'
18 unless find_type_constraint('Bag');
20 sub helper_type { 'Bag' }
22 before 'process_options_for_provides' => sub {
23 my ($self, $options, $name) = @_;
25 # Set some default attribute options here unless already defined
26 if ((my $type = $self->helper_type) && !exists $options->{isa}){
27 $options->{isa} = $type;
30 $options->{default} = sub { +{} } unless exists $options->{default};
34 no Moose::Util::TypeConstraints;
36 # register the alias ...
37 package # hide me from search.cpan.org
38 Moose::Meta::Attribute::Custom::Collection::Bag;
39 sub register_implementation { 'MooseX::AttributeHelpers::Collection::Bag' }
49 MooseX::AttributeHelpers::Collection::Bag
55 use MooseX::AttributeHelpers;
57 has 'word_histogram' => (
58 metaclass => 'Collection::Bag',
60 isa => 'Bag', # optional ... as is defalt
63 'get' => 'get_count_for',
64 'empty' => 'has_any_words',
65 'count' => 'num_words',
66 'delete' => 'delete_word',
72 This module provides a Bag attribute which provides a number of
73 bag-like operations. See L<MooseX::AttributeHelpers::MethodProvider::Bag>
82 =item B<method_provider>
84 =item B<has_method_provider>
88 =item B<process_options_for_provides>
94 All complex software has bugs lurking in it, and this module is no
95 exception. If you find a bug please either email me, or add the bug
100 Stevan Little E<lt>stevan@iinteractive.comE<gt>
102 =head1 COPYRIGHT AND LICENSE
104 Copyright 2007-2008 by Infinity Interactive, Inc.
106 L<http://www.iinteractive.com>
108 This library is free software; you can redistribute it and/or modify
109 it under the same terms as Perl itself.