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