X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst.pm;h=4fe18e78bead702b460a4624e3fc21e01c917613;hp=c206761277dde0e7551178f8578de946ca4d78d4;hb=e80e8542290e1c62b3c6dbee4265691d7ad634c3;hpb=f63c03e47ae0278e50d513b90ecbbdfd67d1a021 diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index c206761..4fe18e7 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -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; @@ -324,8 +323,8 @@ sub stash { if (@_) { my $stash = @_ > 1 ? {@_} : $_[0]; croak('stash takes a hash or hashref') unless ref $stash; - while ( my ( $key, $val ) = each %$stash ) { - $c->{stash}->{$key} = $val; + foreach my $key ( keys %$stash ) { + $c->{stash}->{$key} = $stash->{$key}; } } return $c->{stash}; @@ -650,6 +649,9 @@ L 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 } @@ -1873,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 @@ -1968,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 @@ -2101,12 +2096,8 @@ the plugin name does not begin with C. 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;