From: Stevan Little Date: Fri, 4 May 2007 19:21:57 +0000 (+0000) Subject: * changes for MooseX::IOC X-Git-Tag: 0.18_01~87 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=17618d7865fceb2228d490052f2f44b55b6bf96a;p=gitmo%2FMooseX-AttributeHelpers.git * changes for MooseX::IOC * fixes in the MooseX::AttributeHelpers * better errors in MooseX::Storage --- diff --git a/lib/MooseX/AttributeHelpers/Collection/Array.pm b/lib/MooseX/AttributeHelpers/Collection/Array.pm index 8e0e36c..1bd9976 100644 --- a/lib/MooseX/AttributeHelpers/Collection/Array.pm +++ b/lib/MooseX/AttributeHelpers/Collection/Array.pm @@ -57,9 +57,14 @@ sub _process_options_for_provides { my ($self, $options) = @_; (exists $options->{isa}) || confess "You must define a type with the Array metaclass"; - - my $c = find_type_constraint($options->{isa}) || $options->{isa}; - ( $c && blessed($c) && $c->is_a_type_of('ArrayRef')) + + my $isa = $options->{isa}; + + unless (blessed($isa) && $isa->isa('Moose::Meta::TypeConstraint')) { + $isa = find_type_constraint($isa); + } + + ($isa->is_a_type_of('ArrayRef')) || confess "The type constraint for a Array ($options->{isa}) must be a subtype of ArrayRef"; } diff --git a/lib/MooseX/AttributeHelpers/Collection/Hash.pm b/lib/MooseX/AttributeHelpers/Collection/Hash.pm index 684a1c5..1131ae8 100644 --- a/lib/MooseX/AttributeHelpers/Collection/Hash.pm +++ b/lib/MooseX/AttributeHelpers/Collection/Hash.pm @@ -35,8 +35,14 @@ sub _process_options_for_provides { my ($self, $options) = @_; (exists $options->{isa}) || confess "You must define a type with the Hash metaclass"; - - (find_type_constraint($options->{isa})->is_a_type_of('HashRef')) + + my $isa = $options->{isa}; + + unless (blessed($isa) && $isa->isa('Moose::Meta::TypeConstraint')) { + $isa = find_type_constraint($isa); + } + + ($isa->is_a_type_of('HashRef')) || confess "The type constraint for a Hash ($options->{isa}) must be a subtype of HashRef"; } diff --git a/lib/MooseX/AttributeHelpers/Counter.pm b/lib/MooseX/AttributeHelpers/Counter.pm index 9339472..8851056 100644 --- a/lib/MooseX/AttributeHelpers/Counter.pm +++ b/lib/MooseX/AttributeHelpers/Counter.pm @@ -28,7 +28,13 @@ sub _process_options_for_provides { (exists $options->{isa}) || confess "You must define a type with the Counter metaclass"; - (find_type_constraint($options->{isa})->is_a_type_of('Num')) + my $isa = $options->{isa}; + + unless (blessed($isa) && $isa->isa('Moose::Meta::TypeConstraint')) { + $isa = find_type_constraint($isa); + } + + ($isa->is_a_type_of('Num')) || confess "The type constraint for a Counter ($options->{isa}) must be a subtype of Num"; }