adding in the new junk to this
[gitmo/MooseX-AttributeHelpers.git] / lib / MooseX / AttributeHelpers.pm
CommitLineData
22d869ff 1
2package MooseX::AttributeHelpers;
3
9a976497 4our $VERSION = '0.04';
22d869ff 5our $AUTHORITY = 'cpan:STEVAN';
6
8f7951c9 7use MooseX::AttributeHelpers::Meta::Method::Provided;
8
22d869ff 9use MooseX::AttributeHelpers::Counter;
565fe238 10use MooseX::AttributeHelpers::Number;
457dc4fb 11use MooseX::AttributeHelpers::Collection::List;
22d869ff 12use MooseX::AttributeHelpers::Collection::Array;
13use MooseX::AttributeHelpers::Collection::Hash;
9a976497 14use MooseX::AttributeHelpers::Collection::ImmutableHash;
15use MooseX::AttributeHelpers::Collection::Bag;
22d869ff 16
171;
18
19__END__
20
21=pod
22
23=head1 NAME
24
e295d072 25MooseX::AttributeHelpers - Extend your attribute interfaces
fa4df2e6 26
22d869ff 27=head1 SYNOPSIS
28
e295d072 29 package MyClass;
30 use Moose;
5431dff2 31 use MooseX::AttributeHelpers;
e295d072 32
5431dff2 33 has 'mapping' => (
e295d072 34 metaclass => 'Collection::Hash',
35 is => 'rw',
5431dff2 36 isa => 'HashRef[Str]',
e295d072 37 default => sub { {} },
38 provides => {
39 exists => 'exists_in_mapping',
40 keys => 'ids_in_mapping',
41 get => 'get_mapping',
42 set => 'set_mapping',
43 },
44 );
45
46 # ...
47
48 my $obj = MyClass->new;
49 $obj->set_mapping(4, 'foo');
50 $obj->set_mapping(5, 'bar');
51 $obj->set_mapping(6, 'baz');
52
53 # prints 'bar'
54 print $obj->get_mapping(5) if $obj->exists_in_mapping(5);
55
56 # prints '4, 5, 6'
57 print join ', ', $obj->ids_in_mapping;
58
22d869ff 59=head1 DESCRIPTION
60
e295d072 61While L<Moose> attributes provide you with a way to name your accessors,
62readers, writers, clearers and predicates, this library provides commonly
63used attribute helper methods for more specific types of data.
64
65As seen in the L</SYNOPSIS>, you specify the extension via the
66C<metaclass> parameter. Available meta classes are:
67
68=over
69
70=item L<Number|MooseX::AttributeHelpers::Number>
71
72Common numerical operations.
73
74=item L<Counter|MooseX::AttributeHelpers::Counter>
75
76Methods for incrementing and decrementing a counter attribute.
77
78=item L<Collection::Hash|MooseX::AttributeHelpers::Collection::Hash>
79
80Common methods for hash references.
81
82=item L<Collection::Array|MooseX::AttributeHelpers::Collection::Array>
83
84Common methods for array references.
85
72a41843 86=item L<Collection::List|MooseX::AttributeHelpers::Collection::List>
457dc4fb 87
88Common list methods for array references.
89
e295d072 90=back
91
5431dff2 92=head1 CAVEAT
93
94This is an early release of this module. Right now it is in great need
95of documentation and tests in the test suite. However, we have used this
c91a1347 96module to great success at C<$work> where it has been tested very thoroughly
5431dff2 97and deployed into a major production site.
98
99I plan on getting better docs and tests in the next few releases, but until
100then please refer to the few tests we do have and feel free email and/or
101message me on irc.perl.org if you have any questions.
102
103=head1 TODO
104
105We need tests and docs badly.
106
22d869ff 107=head1 BUGS
108
109All complex software has bugs lurking in it, and this module is no
110exception. If you find a bug please either email me, or add the bug
111to cpan-RT.
112
113=head1 AUTHOR
114
115Stevan Little E<lt>stevan@iinteractive.comE<gt>
116
5431dff2 117B<with contributions from:>
118
119Robert (rlb3) Boone
120
121Chris (perigrin) Prather
122
123Robert (phaylon) Sedlacek
124
38abf787 125Tom (dec) Lanyon
126
22d869ff 127=head1 COPYRIGHT AND LICENSE
128
129Copyright 2007 by Infinity Interactive, Inc.
130
131L<http://www.iinteractive.com>
132
133This library is free software; you can redistribute it and/or modify
134it under the same terms as Perl itself.
135
e295d072 136=cut