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