2 package MooseX::AttributeHelpers::Collection::Hash;
6 our $AUTHORITY = 'cpan:STEVAN';
8 extends 'MooseX::AttributeHelpers::Base';
10 has '+method_constructors' => (
15 return sub { $attr->get_value($_[0])->{$_[1]} };
19 return sub { $attr->get_value($_[0])->{$_[1]} = $_[2] };
23 return sub { scalar keys %{$attr->get_value($_[0])} };
27 return sub { scalar keys %{$attr->get_value($_[0])} ? 1 : 0 };
33 sub _process_options_for_provides {
34 my ($self, $options) = @_;
35 (exists $options->{isa})
36 || confess "You must define a type with the Hash metaclass";
38 (find_type_constraint($options->{isa})->is_subtype_of('HashRef'))
39 || confess "The type constraint for a Hash must be a subtype of HashRef";
44 # register the alias ...
45 package Moose::Meta::Attribute::Custom::Collection::Hash;
46 sub register_implementation { 'MooseX::AttributeHelpers::Collection::Hash' }
65 All complex software has bugs lurking in it, and this module is no
66 exception. If you find a bug please either email me, or add the bug
71 Stevan Little E<lt>stevan@iinteractive.comE<gt>
73 =head1 COPYRIGHT AND LICENSE
75 Copyright 2007 by Infinity Interactive, Inc.
77 L<http://www.iinteractive.com>
79 This library is free software; you can redistribute it and/or modify
80 it under the same terms as Perl itself.