diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2004-12-06 18:25:01 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2004-12-06 18:25:01 +0000 |
commit | 0ffb6c16258b5c39a7417f4563edf0fc7542c9ae (patch) | |
tree | 2242cb28635f99410268f48d0415e97b4c5a5de1 /actionpack/lib/action_controller/dependencies.rb | |
parent | ed14042feac6ff84670958fc3e2017aaacac5856 (diff) | |
download | rails-0ffb6c16258b5c39a7417f4563edf0fc7542c9ae.tar.gz rails-0ffb6c16258b5c39a7417f4563edf0fc7542c9ae.tar.bz2 rails-0ffb6c16258b5c39a7417f4563edf0fc7542c9ae.zip |
Syntax errors and other exceptions thrown outside of an action are now gracefully handled by the dispatcher
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@51 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller/dependencies.rb')
-rw-r--r-- | actionpack/lib/action_controller/dependencies.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/actionpack/lib/action_controller/dependencies.rb b/actionpack/lib/action_controller/dependencies.rb index f087354c63..5a3dd48f89 100644 --- a/actionpack/lib/action_controller/dependencies.rb +++ b/actionpack/lib/action_controller/dependencies.rb @@ -1,11 +1,29 @@ +unless Object.respond_to?(:require_dependency) + Object.send(:define_method, :require_dependency) { |file_name| ActionController::Base.require_dependency(file_name) } +end + module ActionController #:nodoc: module Dependencies #:nodoc: def self.append_features(base) super + + base.class_eval do + # When turned on (which is default), all dependencies are included using "load". This mean that any change is instant in cached + # environments like mod_ruby or FastCGI. When set to false, "require" is used, which is faster but requires server restart to + # be effective. + @@reload_dependencies = true + cattr_accessor :reload_dependencies + end + base.extend(ClassMethods) end module ClassMethods + # Loads the <tt>file_name</tt> if reload_dependencies is true or requires if it's false. + def require_dependency(file_name) + reload_dependencies ? silence_warnings { load("#{file_name}.rb") } : require(file_name) + end + def model(*models) require_dependencies(:model, models) depend_on(:model, models) |