foo
[gitmo/MooseX-AttributeHelpers.git] / lib / MooseX / AttributeHelpers / Collection / Hash.pm
index 1131ae8..01c5e50 100644 (file)
@@ -1,53 +1,21 @@
 
 package MooseX::AttributeHelpers::Collection::Hash;
 use Moose;
-use Moose::Util::TypeConstraints;
 
 our $VERSION   = '0.01';
 our $AUTHORITY = 'cpan:STEVAN';
 
-extends 'MooseX::AttributeHelpers::Base';
-
-has '+method_constructors' => (
-    default => sub {
-        return +{
-            'get' => sub {
-                my $attr = shift;
-                return sub { $attr->get_value($_[0])->{$_[1]} };
-            },    
-            'set' => sub {
-                my $attr = shift;
-                return sub { $attr->get_value($_[0])->{$_[1]} = $_[2] };
-            },    
-            'count' => sub {
-                my $attr = shift;
-                return sub { scalar keys %{$attr->get_value($_[0])} };        
-            },
-            'empty' => sub {
-                my $attr = shift;
-                return sub { scalar keys %{$attr->get_value($_[0])} ? 1 : 0 };        
-            }
-        }
-    }
-);
-
-sub _process_options_for_provides {
-    my ($self, $options) = @_;    
-    (exists $options->{isa})
-        || confess "You must define a type with the Hash metaclass";  
+use MooseX::AttributeHelpers::MethodProvider::Hash;
 
-    my $isa = $options->{isa}; 
+extends 'MooseX::AttributeHelpers::Collection';
 
-    unless (blessed($isa) && $isa->isa('Moose::Meta::TypeConstraint')) {
-        $isa = find_type_constraint($isa);        
-    }
+has '+method_provider' => (
+    default => 'MooseX::AttributeHelpers::MethodProvider::Hash'
+);
 
-    ($isa->is_a_type_of('HashRef'))
-        || confess "The type constraint for a Hash ($options->{isa}) must be a subtype of HashRef";
-}
+sub helper_type { 'HashRef' }
 
 no Moose;
-no Moose::Util::TypeConstraints;
 
 # register the alias ...
 package Moose::Meta::Attribute::Custom::Collection::Hash;