Fix meta() method
[gitmo/Mouse.git] / lib / Mouse / Meta / Module.pm
index 6079af6..07c6853 100755 (executable)
@@ -10,9 +10,7 @@ use Mouse::Util qw/:meta get_code_package not_supported load_class/;
 
 my %METAS;
 
-# because Mouse doesn't introspect existing classes, we're forced to
-# only pay attention to other Mouse classes
-sub _metaclass_cache {
+sub _metaclass_cache { # DEPRECATED
     my($class, $name) = @_;
     return $METAS{$name};
 }
@@ -63,7 +61,7 @@ sub name { $_[0]->{package} }
 
 # add_attribute is an abstract method
 
-sub get_attribute_map {
+sub get_attribute_map { # DEPRECATED
     Carp::cluck('get_attribute_map() has been deprecated');
     return $_[0]->{attributes};
 }
@@ -266,16 +264,18 @@ sub get_method_list {
 
         return if !$serial_id;
 
-        @{$self->{superclasses}} = (); # clear @ISA
-        %{$self->namespace}      = (); # clear the stash
+        # @ISA is a magical variable, so we clear it manually.
+        @{$self->{superclasses}} = () if exists $self->{superclasses};
+
+        # Then, clear the symbol table hash
+        %{$self->namespace} = ();
 
         my $name = $self->name;
         delete $METAS{$name};
 
-        $name =~ s/::\d+$//;
+        $name =~ s/ $serial_id \z//xms;
 
         no strict 'refs';
-
         delete ${$name}{ $serial_id . '::' };
 
         return;