1 package Moose::AttributeHelpers::MethodProvider::ImmutableHash;
5 $VERSION = eval $VERSION;
6 our $AUTHORITY = 'cpan:STEVAN';
9 my ($attr, $reader, $writer) = @_;
10 return sub { CORE::exists $reader->($_[0])->{$_[1]} ? 1 : 0 };
13 sub defined : method {
14 my ($attr, $reader, $writer) = @_;
15 return sub { CORE::defined $reader->($_[0])->{$_[1]} ? 1 : 0 };
19 my ($attr, $reader, $writer) = @_;
22 $reader->($_[0])->{$_[1]}
24 my ( $self, @keys ) = @_;
25 @{ $reader->($self) }{@keys}
31 my ($attr, $reader, $writer) = @_;
32 return sub { CORE::keys %{$reader->($_[0])} };
36 my ($attr, $reader, $writer) = @_;
37 return sub { CORE::values %{$reader->($_[0])} };
41 my ($attr, $reader, $writer) = @_;
43 my $h = $reader->($_[0]);
50 sub elements : method {
51 my ($attr, $reader, $writer) = @_;
53 my $h = $reader->($_[0]);
61 my ($attr, $reader, $writer) = @_;
62 return sub { scalar CORE::keys %{$reader->($_[0])} };
66 my ($attr, $reader, $writer) = @_;
67 return sub { scalar CORE::keys %{$reader->($_[0])} ? 1 : 0 };
78 Moose::AttributeHelpers::MethodProvider::ImmutableHash
82 This is a role which provides the method generators for
83 L<Moose::AttributeHelpers::Collection::ImmutableHash>.
93 =head1 PROVIDED METHODS
99 Returns the number of elements in the list.
103 If the list is populated, returns true. Otherwise, returns false.
107 Returns true if the given key is present in the hash
111 Returns true if the value of a given key is defined
115 Returns an element of the hash by its key.
119 Returns the list of keys in the hash.
123 Returns the list of values in the hash.
127 Returns the key, value pairs in the hash as array references
131 Returns the key, value pairs in the hash as a flattened list
137 All complex software has bugs lurking in it, and this module is no
138 exception. If you find a bug please either email me, or add the bug
143 Stevan Little E<lt>stevan@iinteractive.comE<gt>
145 =head1 COPYRIGHT AND LICENSE
147 Copyright 2007-2009 by Infinity Interactive, Inc.
149 L<http://www.iinteractive.com>
151 This library is free software; you can redistribute it and/or modify
152 it under the same terms as Perl itself.