more doc editing for Native Traits
[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
122a129a 5our $VERSION = '0.89';
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',
e3c07b19 50 }
51 );
52
53=head1 DESCRIPTION
54
55This module provides a Hash attribute which provides a number of
96fd0bec 56hash-like operations.
57
58=head1 PROVIDED METHODS
59
60These methods are implemented in
61L<Moose::Meta::Attribute::Native::MethodProvider::Hash>.
62
63=over 4
64
65=item B<count>
66
af44c00c 67Returns the number of elements in the hash.
96fd0bec 68
69=item B<empty>
70
af44c00c 71If the hash is populated, returns false. Otherwise, returns true.
96fd0bec 72
73=item B<exists>
74
af44c00c 75Returns true if the given key is present in the hash.
96fd0bec 76
77=item B<defined>
78
af44c00c 79Returns true if the value of a given key is defined.
96fd0bec 80
81=item B<get>
82
83Returns an element of the hash by its key.
84
85=item B<keys>
86
87Returns the list of keys in the hash.
88
89=item B<values>
90
91Returns the list of values in the hash.
92
93=item B<kv>
94
af44c00c 95Returns the key, value pairs in the hash as array references.
96fd0bec 96
97=item B<elements>
98
af44c00c 99Returns the key, value pairs in the hash as a flattened list..
96fd0bec 100
101=item B<delete>
102
af44c00c 103Removes the element with the given key.
96fd0bec 104
105=item B<clear>
106
107Unsets the hash entirely.
108
109=item B<set>
110
111Sets the element in the hash at the given key to the given value.
112
113=item B<accessor>
114
115If passed one argument, returns the value of the requested key. If passed two
116arguments, sets the value of the requested key.
117
118=back
e3c07b19 119
120=head1 METHODS
121
122=over 4
123
124=item B<meta>
125
126=item B<method_provider>
127
128=item B<has_method_provider>
129
e3c07b19 130=back
131
132=head1 BUGS
133
134All complex software has bugs lurking in it, and this module is no
135exception. If you find a bug please either email me, or add the bug
136to cpan-RT.
137
138=head1 AUTHOR
139
140Stevan Little E<lt>stevan@iinteractive.comE<gt>
141
142=head1 COPYRIGHT AND LICENSE
143
144Copyright 2007-2009 by Infinity Interactive, Inc.
145
146L<http://www.iinteractive.com>
147
148This library is free software; you can redistribute it and/or modify
149it under the same terms as Perl itself.
150
151=cut