X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FMeta%2FMethod%2FDestructor.pm;h=9f9c67b615b08562fba74d099f772f2864030a52;hb=86850486e3e2425c803df63cb6f10ee89a8d4a76;hp=dcd91cec8f7110fa300618152b3cd0fe85fb8ebd;hpb=8b5074ce1a5038824f1e1177cd00d1bcfec5a9fb;p=gitmo%2FMoose.git diff --git a/lib/Moose/Meta/Method/Destructor.pm b/lib/Moose/Meta/Method/Destructor.pm index dcd91ce..9f9c67b 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.97'; +our $VERSION = '1.12'; $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( @@ -146,7 +149,7 @@ L I L. =over 4 -=item B<< Moose::Meta;:Method::Destructor->new(%options) >> +=item B<< Moose::Meta::Method::Destructor->new(%options) >> This constructs a new object. It accepts the following options: