1 package MooseX::AttributeHelpers::MethodProvider::Hash;
3 use MooseX::AttributeHelpers::Collection::TypeCheck;
6 our $AUTHORITY = 'cpan:STEVAN';
8 with 'MooseX::AttributeHelpers::MethodProvider::ImmutableHash';
11 my ($attr, $reader, $writer) = @_;
15 my ($self, %pairs) = @_;
16 return (values %pairs);
19 my ($self, @pairs) = @_;
20 my $hash = $reader->($self);
22 my $key = shift(@pairs);
23 my $value = shift(@pairs);
24 $hash->{$key} = $value;
31 my ($attr, $reader, $writer) = @_;
32 return sub { %{$reader->($_[0])} = () };
36 my ($attr, $reader, $writer) = @_;
38 my $hashref = $reader->(shift);
39 CORE::delete @{$hashref}{@_};
51 MooseX::AttributeHelpers::MethodProvider::Hash
55 This is a role which provides the method generators for
56 L<MooseX::AttributeHelpers::Collection::Hash>. It consumes
57 L<MooseX::AttributeHelpers::MethodProvider::ImmutableHash>, and thus
58 provides all its methods as wel.
60 =head1 PROVIDED METHODS
66 Returns the number of items in the hash.
68 =item B<delete(@keys)>
70 Deletes the specified keys from the hash.
74 Deletes all keys from the hash.
78 Sets the specified keys to the specified values. You can specify several of
79 these at once, in key => value order.
85 All complex software has bugs lurking in it, and this module is no
86 exception. If you find a bug please either email me, or add the bug
91 Stevan Little E<lt>stevan@iinteractive.comE<gt>
93 =head1 COPYRIGHT AND LICENSE
95 Copyright 2007-2008 by Infinity Interactive, Inc.
97 L<http://www.iinteractive.com>
99 This library is free software; you can redistribute it and/or modify
100 it under the same terms as Perl itself.