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