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