minor docfix
[catagits/Catalyst-Runtime.git] / lib / Catalyst.pm
index c894fed..4fe18e7 100644 (file)
@@ -3,7 +3,6 @@ package Catalyst;
 use strict;
 use base 'Catalyst::Component';
 use bytes;
-use UNIVERSAL::require;
 use Catalyst::Exception;
 use Catalyst::Log;
 use Catalyst::Request;
@@ -25,6 +24,8 @@ use attributes;
 use utf8;
 use Carp qw/croak/;
 
+BEGIN { require 5.008001; }
+
 __PACKAGE__->mk_accessors(
     qw/counter request response state action stack namespace stats/
 );
@@ -202,7 +203,9 @@ The following flags are supported:
 
 =head2 -Debug
 
-Enables debug output.
+Enables debug output. You can also force this setting from the system
+environment with CATALYST_DEBUG or <MYAPP>_DEBUG. The environment settings
+override the app, with <MYAPP>_DEBUG having highest priority.
 
 =head2 -Engine
 
@@ -319,8 +322,9 @@ sub stash {
     my $c = shift;
     if (@_) {
         my $stash = @_ > 1 ? {@_} : $_[0];
-        while ( my ( $key, $val ) = each %$stash ) {
-            $c->{stash}->{$key} = $val;
+       croak('stash takes a hash or hashref') unless ref $stash;
+        foreach my $key ( keys %$stash ) {
+            $c->{stash}->{$key} = $stash->{$key};
         }
     }
     return $c->{stash};
@@ -488,7 +492,7 @@ Gets a L<Catalyst::Model> instance by name.
     $c->model('Foo')->do_stuff;
 
 If the name is omitted, it will look for a config setting 'default_model',
-or check if there is only one model, and forward to it if that's the case.
+or check if there is only one view, and return it if that's the case.
 
 =cut
 
@@ -645,6 +649,9 @@ L<Catalyst::Log> man page.
 
 Overload to enable debug messages (same as -Debug option).
 
+Note that this is a static method, not an accessor and should be overloaded
+by declaring "sub debug { 1 }" in your MyApp.pm, not by calling $c->debug(1).
+
 =cut
 
 sub debug { 0 }
@@ -1868,11 +1875,8 @@ sub setup_dispatcher {
         $dispatcher = $class->dispatcher_class;
     }
 
-    $dispatcher->require;
-
-    if ($@) {
-        Catalyst::Exception->throw(
-            message => qq/Couldn't load dispatcher "$dispatcher", "$@"/ );
+    unless (Class::Inspector->loaded($dispatcher)) {
+        require Class::Inspector->filename($dispatcher);
     }
 
     # dispatcher instance
@@ -1963,12 +1967,8 @@ sub setup_engine {
         $engine = $class->engine_class;
     }
 
-    $engine->require;
-
-    if ($@) {
-        Catalyst::Exception->throw( message =>
-qq/Couldn't load engine "$engine" (maybe you forgot to install it?), "$@"/
-        );
+    unless (Class::Inspector->loaded($engine)) {
+        require Class::Inspector->filename($engine);
     }
 
     # check for old engines that are no longer compatible
@@ -2096,12 +2096,8 @@ the plugin name does not begin with C<Catalyst::Plugin::>.
         my ( $proto, $plugin, $instant ) = @_;
         my $class = ref $proto || $proto;
 
-        $plugin->require;
-
-        if ( my $error = $@ ) {
-            my $type = $instant ? "instant " : '';
-            Catalyst::Exception->throw(
-                message => qq/Couldn't load ${type}plugin "$plugin", $error/ );
+        unless (Class::Inspector->loaded($plugin)) {
+            require Class::Inspector->filename($plugin);
         }
 
         $proto->_plugins->{$plugin} = 1;