2 package MooseX::AttributeHelpers;
5 our $AUTHORITY = 'cpan:STEVAN';
7 use MooseX::AttributeHelpers::Meta::Method::Provided;
9 use MooseX::AttributeHelpers::Trait::Counter;
10 use MooseX::AttributeHelpers::Trait::Number;
11 use MooseX::AttributeHelpers::Trait::String;
12 use MooseX::AttributeHelpers::Trait::Collection::List;
13 use MooseX::AttributeHelpers::Trait::Collection::Array;
14 use MooseX::AttributeHelpers::Trait::Collection::Hash;
15 use MooseX::AttributeHelpers::Trait::Collection::ImmutableHash;
17 use MooseX::AttributeHelpers::Counter;
18 use MooseX::AttributeHelpers::Number;
19 use MooseX::AttributeHelpers::String;
20 use MooseX::AttributeHelpers::Collection::List;
21 use MooseX::AttributeHelpers::Collection::Array;
22 use MooseX::AttributeHelpers::Collection::Hash;
23 use MooseX::AttributeHelpers::Collection::ImmutableHash;
24 use MooseX::AttributeHelpers::Collection::Bag;
34 MooseX::AttributeHelpers - Extend your attribute interfaces
40 use MooseX::AttributeHelpers;
43 metaclass => 'Collection::Hash',
45 isa => 'HashRef[Str]',
46 default => sub { {} },
48 exists => 'exists_in_mapping',
49 keys => 'ids_in_mapping',
57 my $obj = MyClass->new;
58 $obj->set_mapping(4, 'foo');
59 $obj->set_mapping(5, 'bar');
60 $obj->set_mapping(6, 'baz');
63 print $obj->get_mapping(5) if $obj->exists_in_mapping(5);
66 print join ', ', $obj->ids_in_mapping;
70 While L<Moose> attributes provide you with a way to name your accessors,
71 readers, writers, clearers and predicates, this library provides commonly
72 used attribute helper methods for more specific types of data.
74 As seen in the L</SYNOPSIS>, you specify the extension via the
75 C<metaclass> parameter. Available meta classes are:
79 =item L<Number|MooseX::AttributeHelpers::Number>
81 Common numerical operations.
83 =item L<Counter|MooseX::AttributeHelpers::Counter>
85 Methods for incrementing and decrementing a counter attribute.
87 =item L<Collection::Hash|MooseX::AttributeHelpers::Collection::Hash>
89 Common methods for hash references.
91 =item L<Collection::Array|MooseX::AttributeHelpers::Collection::Array>
93 Common methods for array references.
95 =item L<Collection::List|MooseX::AttributeHelpers::Collection::List>
97 Common list methods for array references.
103 This is an early release of this module. Right now it is in great need
104 of documentation and tests in the test suite. However, we have used this
105 module to great success at C<$work> where it has been tested very thoroughly
106 and deployed into a major production site.
108 I plan on getting better docs and tests in the next few releases, but until
109 then please refer to the few tests we do have and feel free email and/or
110 message me on irc.perl.org if you have any questions.
114 We need tests and docs badly.
118 All complex software has bugs lurking in it, and this module is no
119 exception. If you find a bug please either email me, or add the bug
124 Stevan Little E<lt>stevan@iinteractive.comE<gt>
126 B<with contributions from:>
130 Chris (perigrin) Prather
132 Robert (phaylon) Sedlacek
138 =head1 COPYRIGHT AND LICENSE
140 Copyright 2007, 2008 by Infinity Interactive, Inc.
142 L<http://www.iinteractive.com>
144 This library is free software; you can redistribute it and/or modify
145 it under the same terms as Perl itself.