X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FMeta%2FMethod%2FDestructor.pm;h=45bc3ee7a605599c40bbb76bb8b216e1a42371b8;hb=efa728b4984ddf1611bc9931fbc209438459652c;hp=35f00c9fa3ab818209f67d8e3aa8bf2d3d20090c;hpb=b7ef2be4b4b814c7ef52b96cc33e7fb4581428ba;p=gitmo%2FMoose.git diff --git a/lib/Moose/Meta/Method/Destructor.pm b/lib/Moose/Meta/Method/Destructor.pm index 35f00c9..45bc3ee 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.95'; +our $VERSION = '1.15'; $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: