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 { +{} }
34 unless exists $options->{default};
38 no Moose::Util::TypeConstraints;
40 # register the alias ...
41 package # hide me from search.cpan.org
42 Moose::Meta::Attribute::Custom::Trait::Collection::Bag;
43 sub register_implementation {
44 'Moose::AttributeHelpers::Trait::Collection::Bag'
55 Moose::AttributeHelpers::Collection::Bag
61 use Moose::AttributeHelpers;
63 has 'word_histogram' => (
64 metaclass => 'Collection::Bag',
66 isa => 'Bag', # optional ... as is defalt
69 get_count_for => 'get',
70 has_any_words => 'empty',
72 delete_word => 'delete',
78 This module provides a Bag attribute which provides a number of
79 bag-like operations. See L<Moose::AttributeHelpers::MethodProvider::Bag>
88 =item B<method_provider>
90 =item B<has_method_provider>
94 =item B<process_options_for_handles>
100 All complex software has bugs lurking in it, and this module is no
101 exception. If you find a bug please either email me, or add the bug
106 Stevan Little E<lt>stevan@iinteractive.comE<gt>
108 =head1 COPYRIGHT AND LICENSE
110 Copyright 2007-2009 by Infinity Interactive, Inc.
112 L<http://www.iinteractive.com>
114 This library is free software; you can redistribute it and/or modify
115 it under the same terms as Perl itself.