bump version to 0.89_01
[gitmo/Moose.git] / lib / Moose / Meta / Attribute / Native / Trait / Hash.pm
CommitLineData
e3c07b19 1
c466e58f 2package Moose::Meta::Attribute::Native::Trait::Hash;
e3c07b19 3use Moose::Role;
4
9039e8ec 5our $VERSION = '0.89_01';
e3c07b19 6$VERSION = eval $VERSION;
7our $AUTHORITY = 'cpan:STEVAN';
8
c466e58f 9use Moose::Meta::Attribute::Native::MethodProvider::Hash;
e3c07b19 10
c466e58f 11with 'Moose::Meta::Attribute::Native::Trait';
e3c07b19 12
13has 'method_provider' => (
14 is => 'ro',
15 isa => 'ClassName',
16 predicate => 'has_method_provider',
c466e58f 17 default => 'Moose::Meta::Attribute::Native::MethodProvider::Hash'
e3c07b19 18);
19
2e069f5a 20sub _helper_type { 'HashRef' }
e3c07b19 21
22no Moose::Role;
23
e3c07b19 241;
25
26__END__
27
28=pod
29
30=head1 NAME
31
c466e58f 32Moose::Meta::Attribute::Native::Trait::Hash
e3c07b19 33
34=head1 SYNOPSIS
35
36 package Stuff;
37 use Moose;
e3c07b19 38
39 has 'options' => (
96fd0bec 40 traits => ['Hash'],
e3c07b19 41 is => 'ro',
42 isa => 'HashRef[Str]',
43 default => sub { {} },
5f3663b2 44 handles => {
af44c00c 45 set_option => 'set',
46 get_option => 'get',
47 has_no_options => 'empty',
48 num_options => 'count',
49 delete_option => 'delete',
8396a437 50 pairs => 'kv',
9610c1d2 51 },
e3c07b19 52 );
53
54=head1 DESCRIPTION
55
56This module provides a Hash attribute which provides a number of
8396a437 57hash-like operations.
96fd0bec 58
59=head1 PROVIDED METHODS
60
61These methods are implemented in
62L<Moose::Meta::Attribute::Native::MethodProvider::Hash>.
63
64=over 4
65
8396a437 66=item B<get($key)>
96fd0bec 67
8396a437 68Returns an element of the hash by its key.
96fd0bec 69
8396a437 70=item B<set($key)>
96fd0bec 71
8396a437 72Sets the element in the hash at the given key to the given value.
96fd0bec 73
8396a437 74=item B<delete($key)>
96fd0bec 75
8396a437 76Removes the element with the given key.
96fd0bec 77
8396a437 78=item B<keys>
96fd0bec 79
8396a437 80Returns the list of keys in the hash.
96fd0bec 81
8396a437 82=item B<exists($key)>
96fd0bec 83
8396a437 84Returns true if the given key is present in the hash.
96fd0bec 85
8396a437 86=item B<defined($key)>
96fd0bec 87
8396a437 88Returns true if the value of a given key is defined.
96fd0bec 89
90=item B<values>
91
92Returns the list of values in the hash.
93
94=item B<kv>
95
8396a437 96Returns the key/value pairs in the hash as an array of array references.
97
98 for my $pair ( $object->options->pairs ) {
99 print "$pair->[0] = $pair->[1]\n";
100 }
96fd0bec 101
102=item B<elements>
103
8396a437 104Returns the key/value pairs in the hash as a flattened list..
96fd0bec 105
8396a437 106=item B<clear>
96fd0bec 107
8396a437 108Resets the hash to an empty value, like C<%hash = ()>.
96fd0bec 109
8396a437 110=item B<count>
96fd0bec 111
8396a437 112Returns the number of elements in the hash.
96fd0bec 113
8396a437 114=item B<empty>
96fd0bec 115
8396a437 116If the hash is populated, returns false. Otherwise, returns true.
96fd0bec 117
118=item B<accessor>
119
8396a437 120If passed one argument, returns the value of the specified key. If passed two
121arguments, sets the value of the specified key.
96fd0bec 122
123=back
e3c07b19 124
125=head1 METHODS
126
127=over 4
128
129=item B<meta>
130
131=item B<method_provider>
132
133=item B<has_method_provider>
134
e3c07b19 135=back
136
137=head1 BUGS
138
139All complex software has bugs lurking in it, and this module is no
140exception. If you find a bug please either email me, or add the bug
141to cpan-RT.
142
143=head1 AUTHOR
144
145Stevan Little E<lt>stevan@iinteractive.comE<gt>
146
147=head1 COPYRIGHT AND LICENSE
148
149Copyright 2007-2009 by Infinity Interactive, Inc.
150
151L<http://www.iinteractive.com>
152
153This library is free software; you can redistribute it and/or modify
154it under the same terms as Perl itself.
155
156=cut