add %INC entry setting to Web::Simple import() method
Matt S Trout [Sat, 21 Nov 2009 21:56:00 +0000 (16:56 -0500)]
lib/Web/Simple.pm

index f3bf5a5..f990013 100644 (file)
@@ -36,6 +36,8 @@ sub _export_into {
     require Web::Simple::Application;
     unshift(@{"${app_package}::ISA"}, 'Web::Simple::Application');
   }
+  (my $name = $app_package) =~ s/::/\//g;
+  $INC{"${name}.pm"} = 'Set by "use Web::Simple;" invocation';
 }
 
 =head1 NAME
@@ -143,6 +145,16 @@ use $self in dispatch subs without violating strict (Web::Simple::Application
 arranges for dispatch subroutines to have the correct $self in scope when
 this happens).
 
+Finally, import sets
+
+  $INC{"NameOfApplication.pm"} = 'Set by "use Web::Simple;" invocation';
+
+so that perl will not attempt to load the application again even if
+
+  require NameOfApplication;
+
+is encountered in other code.
+
 =head1 EXPORTED SUBROUTINES
 
 =head2 default_config