X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMouse%2FMeta%2FMethod%2FDestructor.pm;h=df3d4898ee206f7c422ae4eca1d80bb810dc6660;hb=refs%2Ftags%2F0.40_04;hp=7775a14f76befc309917f596dfc607fa170215f9;hpb=380e1cd7159fdf0efd57348736ca901825e1e4e8;p=gitmo%2FMouse.git diff --git a/lib/Mouse/Meta/Method/Destructor.pm b/lib/Mouse/Meta/Method/Destructor.pm index 7775a14..df3d489 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(get_code_ref); # 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 (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 } ... @@ -36,3 +45,18 @@ 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.40_04 + +=head1 SEE ALSO + +L + +=cut