X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FMeta%2FMethod%2FDestructor.pm;h=e1fcf89cb116374eec57539f03335d9f42090306;hb=ae7820b1b884344a7ee90d94b484ca46459eb7b1;hp=d24718a6705cd33564ad51301f09d4dfa4230fe3;hpb=26a08c157f47d613aab9376a85512ae73ec34482;p=gitmo%2FMoose.git diff --git a/lib/Moose/Meta/Method/Destructor.pm b/lib/Moose/Meta/Method/Destructor.pm index d24718a..e1fcf89 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.93_01'; +our $VERSION = '1.06'; $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(