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