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 => 'is_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>.
66 =item B<get($key, $key2, $key3...)>
68 Returns values from the hash.
70 In list context return a list of values in the hash for the given keys.
71 In scalar context returns the value for the last key specified.
73 =item B<set($key => $value, $key2 => $value2 ...)>
75 Sets the elements in the hash to the given values.
79 Removes the element with the given key.
83 Returns the list of keys in the hash.
87 Returns true if the given key is present in the hash.
89 =item B<defined($key)>
91 Returns true if the value of a given key is defined.
95 Returns the list of values in the hash.
99 Returns the key/value pairs in the hash as an array of array references.
101 for my $pair ( $object->options->pairs ) {
102 print "$pair->[0] = $pair->[1]\n";
107 Returns the key/value pairs in the hash as a flattened list..
111 Resets the hash to an empty value, like C<%hash = ()>.
115 Returns the number of elements in the hash.
119 If the hash is populated, returns false. Otherwise, returns true.
123 If passed one argument, returns the value of the specified key. If passed two
124 arguments, sets the value of the specified key.
134 =item B<method_provider>
136 =item B<has_method_provider>
142 All complex software has bugs lurking in it, and this module is no
143 exception. If you find a bug please either email me, or add the bug
148 Stevan Little E<lt>stevan@iinteractive.comE<gt>
150 =head1 COPYRIGHT AND LICENSE
152 Copyright 2007-2009 by Infinity Interactive, Inc.
154 L<http://www.iinteractive.com>
156 This library is free software; you can redistribute it and/or modify
157 it under the same terms as Perl itself.