2 package MooseX::AttributeHelpers::Collection::Hash;
6 our $AUTHORITY = 'cpan:STEVAN';
8 extends 'MooseX::AttributeHelpers::Collection';
10 sub helper_type { 'HashRef' }
12 has '+method_constructors' => (
17 return sub { exists $attr->get_value($_[0])->{$_[1]} ? 1 : 0 };
21 return sub { $attr->get_value($_[0])->{$_[1]} };
25 if ($attr->has_container_type) {
26 my $container_type_constraint = $attr->container_type_constraint;
28 ($container_type_constraint->check($_[2]))
29 || confess "Value " . ($_[2]||'undef') . " did not pass container type constraint";
30 $attr->get_value($_[0])->{$_[1]} = $_[2]
34 return sub { $attr->get_value($_[0])->{$_[1]} = $_[2] };
39 return sub { keys %{$attr->get_value($_[0])} };
43 return sub { values %{$attr->get_value($_[0])} };
47 return sub { scalar keys %{$attr->get_value($_[0])} };
51 return sub { scalar keys %{$attr->get_value($_[0])} ? 1 : 0 };
55 return sub { delete $attr->get_value($_[0])->{$_[1]} };
63 # register the alias ...
64 package Moose::Meta::Attribute::Custom::Collection::Hash;
65 sub register_implementation { 'MooseX::AttributeHelpers::Collection::Hash' }
84 All complex software has bugs lurking in it, and this module is no
85 exception. If you find a bug please either email me, or add the bug
90 Stevan Little E<lt>stevan@iinteractive.comE<gt>
92 =head1 COPYRIGHT AND LICENSE
94 Copyright 2007 by Infinity Interactive, Inc.
96 L<http://www.iinteractive.com>
98 This library is free software; you can redistribute it and/or modify
99 it under the same terms as Perl itself.