From: Yuval Kogman Date: Tue, 12 Aug 2008 18:37:13 +0000 (+0000) Subject: move Devel::GlobalDestruction usage to MOP.pm so that when it fails to load and we... X-Git-Tag: 0_64_01~32 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=712ecd187f27b90f67f332cc95905cb9567aa582;p=gitmo%2FClass-MOP.git move Devel::GlobalDestruction usage to MOP.pm so that when it fails to load and we use a constant instead it's not registered as a method of Class::MOP::Class --- diff --git a/lib/Class/MOP.pm b/lib/Class/MOP.pm index 7ed4a4b..6148129 100644 --- a/lib/Class/MOP.pm +++ b/lib/Class/MOP.pm @@ -21,6 +21,12 @@ BEGIN { # this is either part of core or set up appropriately by MRO::Compat *check_package_cache_flag = \&mro::get_pkg_gen; + + eval { + require Devel::GlobalDestruction; + Devel::GlobalDestruction->import("in_global_destruction"); + 1; + } or *in_global_destruction = sub () { '' }; } diff --git a/lib/Class/MOP/Class.pm b/lib/Class/MOP/Class.pm index 79c07b4..33ed1e9 100644 --- a/lib/Class/MOP/Class.pm +++ b/lib/Class/MOP/Class.pm @@ -213,15 +213,6 @@ sub check_metaclass_compatability { return $class->create($package_name, %options); } - BEGIN { - local $@; - eval { - require Devel::GlobalDestruction; - Devel::GlobalDestruction->import("in_global_destruction"); - 1; - } or *in_global_destruction = sub () { '' }; - } - # NOTE: # this will only get called for # anon-classes, all other calls @@ -231,7 +222,7 @@ sub check_metaclass_compatability { sub DESTROY { my $self = shift; - return if in_global_destruction; # it'll happen soon anyway and this just makes things more complicated + return if Class::MOP::in_global_destruction; # it'll happen soon anyway and this just makes things more complicated no warnings 'uninitialized'; return unless $self->name =~ /^$ANON_CLASS_PREFIX/;