X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FMeta%2FMethod%2FDestructor.pm;h=abde763b6e492144cec1eff134651d45fc5114d9;hb=576cd474fc09bba92843e299a33dd2634629a930;hp=e3471911c39bddd9e40ed33f2a8767f3892bc9df;hpb=2e7576bdd6c4a179beadc2d21623c6cad1d66469;p=gitmo%2FMoose.git diff --git a/lib/Moose/Meta/Method/Destructor.pm b/lib/Moose/Meta/Method/Destructor.pm index e347191..abde763 100644 --- a/lib/Moose/Meta/Method/Destructor.pm +++ b/lib/Moose/Meta/Method/Destructor.pm @@ -8,7 +8,7 @@ use Devel::GlobalDestruction (); use Scalar::Util 'blessed', 'weaken'; use Try::Tiny (); -our $VERSION = '0.96'; +our $VERSION = '1.03'; $VERSION = eval $VERSION; our $AUTHORITY = 'cpan:STEVAN'; @@ -81,10 +81,14 @@ sub _initialize_body { my @DEMOLISH_methods = $self->associated_metaclass->find_all_methods_by_name('DEMOLISH'); my $source; - if ( @DEMOLISH_methods ) { - $source = 'sub {'; - $source .= 'my $self = shift;' . "\n"; + $source = 'sub {' . "\n"; + $source .= 'my $self = shift;' . "\n"; + $source .= 'return $self->Moose::Object::DESTROY(@_)' . "\n"; + $source .= ' if Scalar::Util::blessed($self) ne '; + $source .= "'" . $self->associated_metaclass->name . "'"; + $source .= ';' . "\n"; + if ( @DEMOLISH_methods ) { $source .= 'local $?;' . "\n"; $source .= 'my $in_global_destruction = Devel::GlobalDestruction::in_global_destruction;' . "\n"; @@ -98,11 +102,10 @@ sub _initialize_body { $source .= q[ Try::Tiny::catch { no warnings 'misc'; die $_ };] . "\n"; $source .= 'return;' . "\n"; - $source .= '}'; - } else { - $source = 'sub { }'; } + $source .= '}'; + warn $source if $self->options->{debug}; my ( $code, $e ) = $self->_compile_code(