2 package Moose::Meta::Attribute::Native::Trait::Hash;
5 our $VERSION = '0.89_01';
6 $VERSION = eval $VERSION;
7 our $AUTHORITY = 'cpan:STEVAN';
9 use Moose::Meta::Attribute::Native::MethodProvider::Hash;
11 with 'Moose::Meta::Attribute::Native::Trait';
13 has 'method_provider' => (
16 predicate => 'has_method_provider',
17 default => 'Moose::Meta::Attribute::Native::MethodProvider::Hash'
20 sub _helper_type { 'HashRef' }
32 Moose::Meta::Attribute::Native::Trait::Hash
42 isa => 'HashRef[Str]',
43 default => sub { {} },
47 has_no_options => 'empty',
48 num_options => 'count',
49 delete_option => 'delete',
56 This module provides a Hash attribute which provides a number of
59 =head1 PROVIDED METHODS
61 These methods are implemented in
62 L<Moose::Meta::Attribute::Native::MethodProvider::Hash>.
68 Returns an element of the hash by its key.
72 Sets the element in the hash at the given key to the given value.
76 Removes the element with the given key.
80 Returns the list of keys in the hash.
84 Returns true if the given key is present in the hash.
86 =item B<defined($key)>
88 Returns true if the value of a given key is defined.
92 Returns the list of values in the hash.
96 Returns the key/value pairs in the hash as an array of array references.
98 for my $pair ( $object->options->pairs ) {
99 print "$pair->[0] = $pair->[1]\n";
104 Returns the key/value pairs in the hash as a flattened list..
108 Resets the hash to an empty value, like C<%hash = ()>.
112 Returns the number of elements in the hash.
116 If the hash is populated, returns false. Otherwise, returns true.
120 If passed one argument, returns the value of the specified key. If passed two
121 arguments, sets the value of the specified key.
131 =item B<method_provider>
133 =item B<has_method_provider>
139 All complex software has bugs lurking in it, and this module is no
140 exception. If you find a bug please either email me, or add the bug
145 Stevan Little E<lt>stevan@iinteractive.comE<gt>
147 =head1 COPYRIGHT AND LICENSE
149 Copyright 2007-2009 by Infinity Interactive, Inc.
151 L<http://www.iinteractive.com>
153 This library is free software; you can redistribute it and/or modify
154 it under the same terms as Perl itself.