X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMouse%2FMeta%2FMethod%2FDestructor.pm;h=24005a244340d9da48f9fabcfdcd4143879bbc65;hb=806806614368604f49f5e27bf64d1b8d96241177;hp=bdaea1bd56171a65bea3e5348aef0ed8e834f850;hpb=6e168432fa69bbe87ff0dd12e355a8b5d99a1a9c;p=gitmo%2FMouse.git diff --git a/lib/Mouse/Meta/Method/Destructor.pm b/lib/Mouse/Meta/Method/Destructor.pm index bdaea1b..24005a2 100644 --- a/lib/Mouse/Meta/Method/Destructor.pm +++ b/lib/Mouse/Meta/Method/Destructor.pm @@ -1,5 +1,5 @@ package Mouse::Meta::Method::Destructor; -use Mouse::Util qw(get_code_ref); # enables strict and warnings +use Mouse::Util qw(:meta); # enables strict and warnings sub _empty_DESTROY{ } @@ -12,27 +12,29 @@ sub _generate_destructor{ my $demolishall = ''; for my $class ($metaclass->linearized_isa) { - if (get_code_ref($class, 'DEMOLISH')) { - $demolishall .= "${class}::DEMOLISH(\$self);\n"; + if (Mouse::Util::get_code_ref($class, 'DEMOLISH')) { + $demolishall .= sprintf "%s::DEMOLISH(\$self, \$Mouse::Util::in_global_destruction);\n", + $class, } } - my $source = sprintf("#line %d %s\n", __LINE__, __FILE__) . <<"..."; + my $source = sprintf(<<'END_DESTROY', __LINE__, __FILE__, $demolishall); +#line %d %s sub { - my \$self = shift; - local \$?; - - my \$e = do{ - local \$@; + my $self = shift; + my $e = do{ + local $?; + local $@; eval{ - $demolishall; + # demolishall + %s; }; - \$@; + $@; }; no warnings 'misc'; - die \$e if \$e; # rethrow + die $e if $e; # rethrow } -... +END_DESTROY my $code; my $e = do{ @@ -53,7 +55,7 @@ Mouse::Meta::Method::Destructor - A Mouse method generator for destructors =head1 VERSION -This document describes Mouse version 0.40_05 +This document describes Mouse version 0.50_07 =head1 SEE ALSO