pass the in_global_destruction state to DEMOLISHALL and DEMOLISH
Jesse Luehrs [Wed, 29 Apr 2009 05:42:10 +0000 (00:42 -0500)]
lib/Moose/Object.pm

index 68364db..cc683d3 100644 (file)
@@ -56,6 +56,7 @@ sub BUILDALL {
 
 sub DEMOLISHALL {
     my $self = shift;
+    my ($in_global_destruction) = @_;
 
     # NOTE: we ask Perl if we even
     # need to do this first, to avoid
@@ -70,7 +71,7 @@ sub DEMOLISHALL {
         || Moose::Meta::Class->initialize( ref $self );
 
     foreach my $method ( $meta->find_all_methods_by_name('DEMOLISH') ) {
-        $method->{code}->execute($self);
+        $method->{code}->execute($self, $in_global_destruction);
     }
 }
 
@@ -80,12 +81,12 @@ sub DESTROY {
         # localize the $@ ...
         local $@;
         # run DEMOLISHALL ourselves, ...
-        $_[0]->DEMOLISHALL;
+        $_[0]->DEMOLISHALL(Class::MOP::in_global_destruction);
         # and return ...
         return;
     }
     # otherwise it is normal destruction
-    $_[0]->DEMOLISHALL;
+    $_[0]->DEMOLISHALL(Class::MOP::in_global_destruction);
 }
 
 # support for UNIVERSAL::DOES ...