sync version # to 0.85
[gitmo/Moose.git] / lib / Moose / AttributeHelpers / Trait / Collection / Bag.pm
CommitLineData
e3c07b19 1
2package Moose::AttributeHelpers::Trait::Collection::Bag;
3use Moose::Role;
4use Moose::Util::TypeConstraints;
5
115601b6 6our $VERSION = '0.85';
e3c07b19 7$VERSION = eval $VERSION;
8our $AUTHORITY = 'cpan:STEVAN';
9
10use Moose::AttributeHelpers::MethodProvider::Bag;
11
12with 'Moose::AttributeHelpers::Trait::Collection';
13
14has 'method_provider' => (
15 is => 'ro',
16 isa => 'ClassName',
17 predicate => 'has_method_provider',
18 default => 'Moose::AttributeHelpers::MethodProvider::Bag'
19);
20
21subtype 'Bag' => as 'HashRef[Int]';
22
23sub helper_type { 'Bag' }
24
25d86888 25before 'process_options_for_handles' => sub {
046c8b5e 26 my ( $self, $options, $name ) = @_;
e3c07b19 27
28 # Set some default attribute options here unless already defined
046c8b5e 29 if ( ( my $type = $self->helper_type ) && !exists $options->{isa} ) {
e3c07b19 30 $options->{isa} = $type;
31 }
32
046c8b5e 33 $options->{default} = sub { +{} }
34 unless exists $options->{default};
e3c07b19 35};
36
37no Moose::Role;
38no Moose::Util::TypeConstraints;
39
40# register the alias ...
41package # hide me from search.cpan.org
42 Moose::Meta::Attribute::Custom::Trait::Collection::Bag;
43sub register_implementation {
44 'Moose::AttributeHelpers::Trait::Collection::Bag'
45}
46
471;
48
49__END__
50
51=pod
52
53=head1 NAME
54
55Moose::AttributeHelpers::Collection::Bag
56
57=head1 SYNOPSIS
58
59 package Stuff;
60 use Moose;
61 use Moose::AttributeHelpers;
62
63 has 'word_histogram' => (
64 metaclass => 'Collection::Bag',
65 is => 'ro',
66 isa => 'Bag', # optional ... as is defalt
5f3663b2 67 handles => {
68 add_word => 'add',
69 get_count_for => 'get',
70 has_any_words => 'empty',
71 num_words => 'count',
72 delete_word => 'delete',
e3c07b19 73 }
74 );
75
76=head1 DESCRIPTION
77
78This module provides a Bag attribute which provides a number of
79bag-like operations. See L<Moose::AttributeHelpers::MethodProvider::Bag>
80for more details.
81
82=head1 METHODS
83
84=over 4
85
86=item B<meta>
87
88=item B<method_provider>
89
90=item B<has_method_provider>
91
92=item B<helper_type>
93
25d86888 94=item B<process_options_for_handles>
e3c07b19 95
96=back
97
98=head1 BUGS
99
100All complex software has bugs lurking in it, and this module is no
101exception. If you find a bug please either email me, or add the bug
102to cpan-RT.
103
104=head1 AUTHOR
105
106Stevan Little E<lt>stevan@iinteractive.comE<gt>
107
108=head1 COPYRIGHT AND LICENSE
109
110Copyright 2007-2009 by Infinity Interactive, Inc.
111
112L<http://www.iinteractive.com>
113
114This library is free software; you can redistribute it and/or modify
115it under the same terms as Perl itself.
116
117=cut