Look up the metaclass in get_method_map instead of blindly calling meta
[gitmo/Moose.git] / lib / Moose / Meta / Role.pm
index 804e78e..a6ff920 100644 (file)
@@ -8,7 +8,7 @@ use metaclass;
 use Scalar::Util 'blessed';
 use Carp         'confess';
 
-our $VERSION   = '0.72';
+our $VERSION   = '0.73';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
@@ -256,7 +256,7 @@ sub update_package_cache_flag {
 ## ------------------------------------------------------------------
 ## subroles
 
-__PACKAGE__->meta->add_attribute('roles' => (
+$META->add_attribute('roles' => (
     reader  => 'get_roles',
     default => sub { [] }
 ));
@@ -323,18 +323,10 @@ sub get_method_map {
                         $map->{$symbol}->body == $code;
 
         my ($pkg, $name) = Class::MOP::get_code_info($code);
+        my $meta = Class::MOP::class_of($pkg);
 
-        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) } # FIXME calls meta
-            && $pkg->meta->isa('Moose::Meta::Role')) {
-            my $role = $pkg->meta->name;
+        if ($meta && $meta->isa('Moose::Meta::Role')) {
+            my $role = $meta->name;
             next unless $self->does_role($role);
         }
         else {
@@ -729,6 +721,10 @@ additional Moose-specific functionality.
 It's API looks a lot like L<Moose::Meta::Class>, but internally it
 implements many things differently. This may change in the future.
 
+=head1 INHERITANCE
+
+C<Moose::Meta::Role> is a subclass of L<Class::MOP::Module>.
+
 =head1 METHODS
 
 =head2 Construction