From: Matt S Trout Date: Thu, 24 May 2012 19:38:18 +0000 (+0000) Subject: optional D::GD usage X-Git-Tag: v0.091008~6 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f57f113347ea478e526ef6befdece0c1eacfca62;p=gitmo%2FMoo.git optional D::GD usage --- diff --git a/Changes b/Changes index 1c31f59..3e33d5c 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,5 @@ + - use D::GD if installed rather than re-adding it as a requirement + 0.091007 - 2012-05-17 - remove stray reference to Devel::GlobalDestruction diff --git a/lib/Moo/_Utils.pm b/lib/Moo/_Utils.pm index 7c2a8f8..24fe665 100644 --- a/lib/Moo/_Utils.pm +++ b/lib/Moo/_Utils.pm @@ -19,7 +19,7 @@ our @EXPORT = qw( _in_global_destruction ); -sub _in_global_destruction; +sub _in_global_destruction (); sub _install_modifier { my ($into, $type, $name, $code) = @_; @@ -89,14 +89,16 @@ sub STANDARD_DESTROY { die $e if $e; # rethrow } -if (defined ${^GLOBAL_PHASE}) { - eval 'sub _in_global_destruction () { ${^GLOBAL_PHASE} eq q[DESTRUCT] }'; +if (eval { require_module('Devel::GlobalDestruction') }) { + *_in_global_destruction = \&Devel::GlobalDestruction::in_global_destruction; +} elsif (defined ${^GLOBAL_PHASE}) { + eval 'sub _in_global_destruction () { ${^GLOBAL_PHASE} eq q[DESTRUCT] }'; } else { eval <<'PP_IGD' or die $@; my ($in_global_destruction, $before_is_installed); -sub _in_global_destruction { $in_global_destruction } +sub _in_global_destruction () { $in_global_destruction } END { # SpeedyCGI runs END blocks every cycle but somehow keeps object instances