load external classes for dynamic schemas only
[dbsrgits/DBIx-Class-Schema-Loader.git] / lib / DBIx / Class / Schema / Loader / Base.pm
index e8ee87b..6cd8368 100644 (file)
@@ -438,13 +438,12 @@ sub _load_external {
     close($fh)
         or croak "Failed to close $real_inc_path: $!";
 
-# load the class too
-    {
+    if ($self->dynamic) { # load the class too
         # turn off redefined warnings
-        $SIG{__WARN__} = sub {};
+        local $SIG{__WARN__} = sub {};
         do $real_inc_path;
+        die $@ if $@;
     }
-    die $@ if $@;
 }
 
 =head2 load