X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst.pm;h=8359312ed83999e9d6cd40dff164c1004cbc5a4f;hp=768e0134b25c67083d1f45b5264df8e071feac52;hb=1e514a515b9b9a740962392fb280cdb11737ff02;hpb=f8ad6ea56eeb4d3a3d5d77cf502651712dfb5e62 diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 768e013..8359312 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; @@ -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/ ); @@ -322,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}; @@ -593,8 +594,6 @@ sub component { $comp = $c->_comp_search($name); return $c->_filter_component( $comp, @_ ) if defined($comp); - - croak("Unable to find component $name"); } return sort keys %{ $c->components }; @@ -1873,11 +1872,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 +1964,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 +2093,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;