1 package MooseX::AttributeHelpers::MethodProvider::Collection::Hash;
2 use MooseX::AttributeHelpers::MethodProvider;
3 use MooseX::AttributeHelpers::MethodProvider::Util qw(type_check);
4 use MooseX::AttributeHelpers::MethodProvider::Collection::ImmutableHash;
7 our $AUTHORITY = 'cpan:STEVAN';
9 add_method_provider 'Collection::Hash' => (
11 consumes => { 'Collection::ImmutableHash' => ':all' },
14 my ($attr, $reader, $writer) = @_;
17 sub { my ($self, %pairs) = @_; 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}{@_};
53 MooseX::AttributeHelpers::MethodProvider::Hash
57 This is a role which provides the method generators for
58 L<MooseX::AttributeHelpers::Collection::Hash>. It consumes
59 L<MooseX::AttributeHelpers::MethodProvider::ImmutableHash>, and thus
60 provides all its methods as wel.
62 =head1 PROVIDED METHODS
68 Returns the number of items in the hash.
70 =item B<delete(@keys)>
72 Deletes the specified keys from the hash.
76 Deletes all keys from the hash.
80 Sets the specified keys to the specified values. You can specify several of
81 these at once, in key => value order.
87 All complex software has bugs lurking in it, and this module is no
88 exception. If you find a bug please either email me, or add the bug
93 Stevan Little E<lt>stevan@iinteractive.comE<gt>
95 =head1 COPYRIGHT AND LICENSE
97 Copyright 2007-2008 by Infinity Interactive, Inc.
99 L<http://www.iinteractive.com>
101 This library is free software; you can redistribute it and/or modify
102 it under the same terms as Perl itself.