push this stuff back into HasMethods and HasAttributes
[gitmo/Class-MOP.git] / lib / Class / MOP / Mixin / HasMethods.pm
index 032fb8d..bd28e40 100644 (file)
@@ -3,7 +3,7 @@ package Class::MOP::Mixin::HasMethods;
 use strict;
 use warnings;
 
-our $VERSION   = '1.04';
+our $VERSION   = '1.09';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
@@ -161,11 +161,12 @@ sub get_method_list {
 
     my $namespace = $self->namespace;
 
-    # Constants will show up as some sort of reference in the namespace hash
-    # ref.
+    # Constants may show up as some sort of non-GLOB reference in the
+    # namespace hash ref, depending on the Perl version.
     return grep {
-               ! ref $namespace->{$_}
-            && *{ $namespace->{$_} }{CODE}
+        defined $namespace->{$_}
+            && ( ref( \$namespace->{$_} ) ne 'GLOB'
+            || *{ $namespace->{$_} }{CODE} )
             && $self->has_method($_)
         }
         keys %{$namespace};
@@ -180,10 +181,24 @@ sub _get_local_methods {
     my $namespace = $self->namespace;
 
     return map { $self->get_method($_) }
-        grep { ! ref $namespace->{$_} && *{ $namespace->{$_} }{CODE} }
+        grep {
+        defined $namespace->{$_}
+            && ( ref $namespace->{$_}
+            || *{ $namespace->{$_} }{CODE} )
+        }
         keys %{$namespace};
 }
 
+sub _restore_metamethods_from {
+    my $self = shift;
+    my ($old_meta) = @_;
+
+    for my $method ($old_meta->_get_local_methods) {
+        $method->_make_compatible_with($self->method_metaclass);
+        $self->add_method($method->name => $method);
+    }
+}
+
 1;
 
 __END__