1 package MooseX::AttributeHelpers::MethodProvider::Collection::ImmutableHash;
2 use MooseX::AttributeHelpers::MethodProvider;
5 our $AUTHORITY = 'cpan:STEVAN';
7 add_method_provider 'Collection::ImmutableHash' => (
11 my ($attr, $reader, $writer) = @_;
12 return sub { CORE::exists $reader->($_[0])->{$_[1]} };
16 my ($attr, $reader, $writer) = @_;
18 my ($self, @keys) = @_;
19 @{ $reader->($self) }{@keys}
24 my ($attr, $reader, $writer) = @_;
25 return sub { CORE::keys %{$reader->($_[0])} };
29 my ($attr, $reader, $writer) = @_;
30 return sub { CORE::values %{$reader->($_[0])} };
34 my ($attr, $reader, $writer) = @_;
36 my $h = $reader->($_[0]);
44 my ($attr, $reader, $writer) = @_;
45 return sub { scalar CORE::keys %{$reader->($_[0])} };
48 # Deprecated. Does the opposite of what it claims to.
50 my ($attr, $reader, $writer) = @_;
51 return sub { scalar CORE::keys %{$reader->($_[0])} ? 1 : 0 };
55 my ($attr, $reader, $writer) = @_;
56 return sub { CORE::keys %{$reader->($_[0])} == 0 };
60 my ($attr, $reader, $writer) = @_;
61 return sub { CORE::keys %{$reader->($_[0])} > 0 };
74 MooseX::AttributeHelpers::MethodProvider::ImmutableHash
78 This module provides the method factories for
79 L<MooseX::AttributeHelpers::Collection::ImmutableHash>.
81 =head1 PROVIDED METHODS
87 Returns the number of items in the hash.
91 DEPRECATED. This was a misleading name for what it does (returns a boolean
92 indicating whether the hash is NOT empty), but we're keeping it for backwards
93 compatibility. Do not use it in new code. Use is_empty or has_items instead,
94 depending on what you meant.
98 Returns a boolean which is true if and only if the hash has no items in it.
102 Returns a boolean which is true if and only if the hash has at least one item.
110 Gets the values specified by @keys from the hash.
122 Returns a list of arrayrefs, each of which is a key => value pair mapping.
128 All complex software has bugs lurking in it, and this module is no
129 exception. If you find a bug please either email me, or add the bug
134 Stevan Little E<lt>stevan@iinteractive.comE<gt>
136 =head1 COPYRIGHT AND LICENSE
138 Copyright 2007-2008 by Infinity Interactive, Inc.
140 L<http://www.iinteractive.com>
142 This library is free software; you can redistribute it and/or modify
143 it under the same terms as Perl itself.