2 package Moose::AttributeHelpers::Trait::Collection::Bag;
4 use Moose::Util::TypeConstraints;
7 $VERSION = eval $VERSION;
8 our $AUTHORITY = 'cpan:STEVAN';
10 use Moose::AttributeHelpers::MethodProvider::Bag;
12 with 'Moose::AttributeHelpers::Trait::Collection';
14 has 'method_provider' => (
17 predicate => 'has_method_provider',
18 default => 'Moose::AttributeHelpers::MethodProvider::Bag'
21 subtype 'Bag' => as 'HashRef[Int]';
23 sub helper_type { 'Bag' }
25 before 'process_options_for_handles' => 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;
39 # register the alias ...
40 package # hide me from search.cpan.org
41 Moose::Meta::Attribute::Custom::Trait::Collection::Bag;
42 sub register_implementation {
43 'Moose::AttributeHelpers::Trait::Collection::Bag'
54 Moose::AttributeHelpers::Collection::Bag
60 use Moose::AttributeHelpers;
62 has 'word_histogram' => (
63 metaclass => 'Collection::Bag',
65 isa => 'Bag', # optional ... as is defalt
68 get_count_for => 'get',
69 has_any_words => 'empty',
71 delete_word => 'delete',
77 This module provides a Bag attribute which provides a number of
78 bag-like operations. See L<Moose::AttributeHelpers::MethodProvider::Bag>
87 =item B<method_provider>
89 =item B<has_method_provider>
93 =item B<process_options_for_handles>
99 All complex software has bugs lurking in it, and this module is no
100 exception. If you find a bug please either email me, or add the bug
105 Stevan Little E<lt>stevan@iinteractive.comE<gt>
107 =head1 COPYRIGHT AND LICENSE
109 Copyright 2007-2009 by Infinity Interactive, Inc.
111 L<http://www.iinteractive.com>
113 This library is free software; you can redistribute it and/or modify
114 it under the same terms as Perl itself.