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] };
25 my ( $self, @keys ) = @_;
26 @{ $reader->($self) }{@keys};
32 my ( $attr, $reader, $writer ) = @_;
33 return sub { CORE::keys %{ $reader->( $_[0] ) } };
37 my ( $attr, $reader, $writer ) = @_;
38 return sub { CORE::values %{ $reader->( $_[0] ) } };
42 my ( $attr, $reader, $writer ) = @_;
44 my $h = $reader->( $_[0] );
45 map { [ $_, $h->{$_} ] } CORE::keys %{$h};
49 sub elements : method {
50 my ( $attr, $reader, $writer ) = @_;
52 my $h = $reader->( $_[0] );
53 map { $_, $h->{$_} } CORE::keys %{$h};
58 my ( $attr, $reader, $writer ) = @_;
59 return sub { scalar CORE::keys %{ $reader->( $_[0] ) } };
63 my ( $attr, $reader, $writer ) = @_;
64 return sub { scalar CORE::keys %{ $reader->( $_[0] ) } ? 1 : 0 };
75 Moose::AttributeHelpers::MethodProvider::ImmutableHash
79 This is a role which provides the method generators for
80 L<Moose::AttributeHelpers::Collection::ImmutableHash>.
90 =head1 PROVIDED METHODS
96 Returns the number of elements in the list.
100 If the list is populated, returns true. Otherwise, returns false.
104 Returns true if the given key is present in the hash
108 Returns true if the value of a given key is defined
112 Returns an element of the hash by its key.
116 Returns the list of keys in the hash.
120 Returns the list of values in the hash.
124 Returns the key, value pairs in the hash as array references
128 Returns the key, value pairs in the hash as a flattened list
134 All complex software has bugs lurking in it, and this module is no
135 exception. If you find a bug please either email me, or add the bug
140 Stevan Little E<lt>stevan@iinteractive.comE<gt>
142 =head1 COPYRIGHT AND LICENSE
144 Copyright 2007-2009 by Infinity Interactive, Inc.
146 L<http://www.iinteractive.com>
148 This library is free software; you can redistribute it and/or modify
149 it under the same terms as Perl itself.