1 package MooseX::AttributeHelpers::MethodProvider::Hash;
5 our $AUTHORITY = 'cpan:STEVAN';
7 with 'MooseX::AttributeHelpers::MethodProvider::ImmutableHash';
10 my ($attr, $reader, $writer) = @_;
11 if ($attr->has_type_constraint && $attr->type_constraint->isa('Moose::Meta::TypeConstraint::Parameterized')) {
12 my $container_type_constraint = $attr->type_constraint->type_parameter;
14 ($container_type_constraint->check($_[2]))
15 || confess "Value " . ($_[2]||'undef') . " did not pass container type constraint";
16 $reader->($_[0])->{$_[1]} = $_[2]
20 return sub { $reader->($_[0])->{$_[1]} = $_[2] };
25 my ($attr, $reader, $writer) = @_;
26 return sub { %{$reader->($_[0])} = () };
30 my ($attr, $reader, $writer) = @_;
31 return sub { CORE::delete $reader->($_[0])->{$_[1]} };
42 MooseX::AttributeHelpers::MethodProvider::Hash
46 This is a role which provides the method generators for
47 L<MooseX::AttributeHelpers::Collection::Hash>.
49 This role is composed from the
50 L<MooseX::AttributeHelpers::Collection::ImmutableHash> role.
60 =head1 PROVIDED METHODS
88 All complex software has bugs lurking in it, and this module is no
89 exception. If you find a bug please either email me, or add the bug
94 Stevan Little E<lt>stevan@iinteractive.comE<gt>
96 =head1 COPYRIGHT AND LICENSE
98 Copyright 2007 by Infinity Interactive, Inc.
100 L<http://www.iinteractive.com>
102 This library is free software; you can redistribute it and/or modify
103 it under the same terms as Perl itself.