Don't use get_method_map either
[gitmo/Perl-Critic-Dynamic-Moose.git] / lib / Perl / Critic / Policy / DynamicMoose / RequireMethodModifiers.pm
index 561b5c8..54a6efd 100644 (file)
@@ -14,16 +14,21 @@ sub violates_metaclass {
 
     my @violations;
 
-    my $map = $meta->get_method_map;
+    for my $name ($meta->get_method_list) {
+        my $method = $meta->get_method($name);
 
-    for my $name (keys %$map) {
-        my $method = $map->{$name};
-
-        # Modifiers are always fine.
-        next if $method->isa('Class::MOP::Method::Wrapped')
-             || $method->isa('Moose::Meta::Method::Overridden')
+        # override and augment modifiers are always fine.
+        next if $method->isa('Moose::Meta::Method::Overridden')
              || $method->isa('Moose::Meta::Method::Augmented');
 
+        # Since we can implicitly override and wrap in the same class, we
+        # need to be a little more careful here.
+        if ($method->isa('Class::MOP::Method::Wrapped')) {
+            my $orig_method = $method->get_original_method;
+            next if $method->associated_metaclass->name
+                 ne $orig_method->associated_metaclass->name;
+        }
+
         # Generated methods
         next if $method->isa('Class::MOP::Method::Generated');