X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=blobdiff_plain;f=lib%2FMouse%2FMeta%2FMethod%2FDestructor.pm;h=96ada5f0c9960b2db086bbcb051528986974c120;hp=66f4709f739dc68372a0f1165e52340941465a11;hb=01e830f796a9ecdec0d977f2b88110363ebf013f;hpb=0126c27c413cb63f67e66e09b0fdfeb92117503a diff --git a/lib/Mouse/Meta/Method/Destructor.pm b/lib/Mouse/Meta/Method/Destructor.pm index 66f4709..96ada5f 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; # enables strict and warnings +use Mouse::Util qw(:meta); # enables strict and warnings sub _empty_DESTROY{ } @@ -12,8 +12,7 @@ sub _generate_destructor{ my $demolishall = ''; for my $class ($metaclass->linearized_isa) { - no strict 'refs'; - if (*{$class . '::DEMOLISH'}{CODE}) { + if (Mouse::Util::get_code_ref($class, 'DEMOLISH')) { $demolishall .= "${class}::DEMOLISH(\$self);\n"; } } @@ -21,7 +20,17 @@ sub _generate_destructor{ my $source = sprintf("#line %d %s\n", __LINE__, __FILE__) . <<"..."; sub { my \$self = shift; - $demolishall; + local \$?; + + my \$e = do{ + local \$@; + eval{ + $demolishall; + }; + \$@; + }; + no warnings 'misc'; + die \$e if \$e; # rethrow } ... @@ -37,3 +46,17 @@ sub _generate_destructor{ 1; __END__ + +=head1 NAME + +Mouse::Meta::Method::Destructor - A Mouse method generator for destructors + +=head1 VERSION + +This document describes Mouse version 0.49 + +=head1 SEE ALSO + +L + +=cut