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 { $attr->get_value($_[0])->{$_[1]} };
21 if ($attr->has_container_type) {
22 my $container_type_constraint = $attr->container_type_constraint;
24 ($container_type_constraint->check($_[2]))
25 || confess "Value $_[2] did not pass container type constraint";
26 $attr->get_value($_[0])->{$_[1]} = $_[2]
30 return sub { $attr->get_value($_[0])->{$_[1]} = $_[2] };
35 return sub { keys %{$attr->get_value($_[0])} };
39 return sub { values %{$attr->get_value($_[0])} };
43 return sub { scalar keys %{$attr->get_value($_[0])} };
47 return sub { scalar keys %{$attr->get_value($_[0])} ? 1 : 0 };
55 # register the alias ...
56 package Moose::Meta::Attribute::Custom::Collection::Hash;
57 sub register_implementation { 'MooseX::AttributeHelpers::Collection::Hash' }
76 All complex software has bugs lurking in it, and this module is no
77 exception. If you find a bug please either email me, or add the bug
82 Stevan Little E<lt>stevan@iinteractive.comE<gt>
84 =head1 COPYRIGHT AND LICENSE
86 Copyright 2007 by Infinity Interactive, Inc.
88 L<http://www.iinteractive.com>
90 This library is free software; you can redistribute it and/or modify
91 it under the same terms as Perl itself.