1 package MooseX::AttributeHelpers::MethodProvider::Hash;
5 our $AUTHORITY = 'cpan:STEVAN';
8 my ($attr, $reader, $writer) = @_;
9 return sub { exists $reader->($_[0])->{$_[1]} ? 1 : 0 };
13 my ($attr, $reader, $writer) = @_;
14 return sub { $reader->($_[0])->{$_[1]} };
18 my ($attr, $reader, $writer) = @_;
19 if ($attr->has_container_type) {
20 my $container_type_constraint = $attr->container_type_constraint;
22 ($container_type_constraint->check($_[2]))
23 || confess "Value " . ($_[2]||'undef') . " did not pass container type constraint";
24 $reader->($_[0])->{$_[1]} = $_[2]
28 return sub { $reader->($_[0])->{$_[1]} = $_[2] };
33 my ($attr, $reader, $writer) = @_;
34 return sub { keys %{$reader->($_[0])} };
38 my ($attr, $reader, $writer) = @_;
39 return sub { values %{$reader->($_[0])} };
43 my ($attr, $reader, $writer) = @_;
44 return sub { scalar keys %{$reader->($_[0])} };
48 my ($attr, $reader, $writer) = @_;
49 return sub { scalar keys %{$reader->($_[0])} ? 1 : 0 };
53 my ($attr, $reader, $writer) = @_;
54 return sub { %{$reader->($_[0])} = () };
58 my ($attr, $reader, $writer) = @_;
59 return sub { delete $reader->($_[0])->{$_[1]} };
70 MooseX::AttributeHelpers::MethodProvider::Hash
74 This is a role which provides the method generators for
75 L<MooseX::AttributeHelpers::Collection::Hash>.
85 =head1 PROVIDED METHODS
111 All complex software has bugs lurking in it, and this module is no
112 exception. If you find a bug please either email me, or add the bug
117 Stevan Little E<lt>stevan@iinteractive.comE<gt>
119 =head1 COPYRIGHT AND LICENSE
121 Copyright 2007 by Infinity Interactive, Inc.
123 L<http://www.iinteractive.com>
125 This library is free software; you can redistribute it and/or modify
126 it under the same terms as Perl itself.