From: Stevan Little Date: Fri, 14 Sep 2007 05:23:54 +0000 (+0000) Subject: being more cautious about how we use ->meta X-Git-Tag: 0_26~20 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4f8f3aab9663cb29b0d85c7681cc2a381a71d4a3;p=gitmo%2FMoose.git being more cautious about how we use ->meta --- diff --git a/lib/Moose/Meta/Class.pm b/lib/Moose/Meta/Class.pm index 092f641..e398eb1 100644 --- a/lib/Moose/Meta/Class.pm +++ b/lib/Moose/Meta/Class.pm @@ -9,7 +9,7 @@ use Class::MOP; use Carp 'confess'; use Scalar::Util 'weaken', 'blessed', 'reftype'; -our $VERSION = '0.14'; +our $VERSION = '0.15'; our $AUTHORITY = 'cpan:STEVAN'; use Moose::Meta::Method::Overriden; @@ -125,7 +125,16 @@ sub get_method_map { my $gv = B::svref_2object($code)->GV; my $pkg = $gv->STASH->NAME; - if ($pkg->can('meta') && $pkg->meta && $pkg->meta->isa('Moose::Meta::Role')) { + if ($pkg->can('meta') + # NOTE: + # we don't know what ->meta we are calling + # here, so we need to be careful cause it + # just might blow up at us, or just complain + # loudly (in the case of Curses.pm) so we + # just be a little overly cautious here. + # - SL + && eval { no warnings; blessed($pkg->meta) } + && $pkg->meta->isa('Moose::Meta::Role')) { #my $role = $pkg->meta->name; #next unless $self->does_role($role); } diff --git a/lib/Moose/Util/TypeConstraints.pm b/lib/Moose/Util/TypeConstraints.pm index 8dd8170..5d01e2c 100644 --- a/lib/Moose/Util/TypeConstraints.pm +++ b/lib/Moose/Util/TypeConstraints.pm @@ -73,6 +73,9 @@ my $REGISTRY = Moose::Meta::TypeConstraint::Registry->new; sub _get_type_constraint_registry { $REGISTRY } sub _dump_type_constraints { $REGISTRY->dump } +# NOTE: +# this method breaks down the sugar +# from the functions below. sub _create_type_constraint ($$$;$$) { my $name = shift; my $parent = shift; @@ -97,6 +100,7 @@ sub _create_type_constraint ($$$;$$) { } $parent = $REGISTRY->get_type_constraint($parent) if defined $parent; + my $constraint = Moose::Meta::TypeConstraint->new( name => $name || '__ANON__', parent => $parent,