aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2008-07-24 11:58:26 -0500
committerJoshua Peek <josh@joshpeek.com>2008-07-24 11:58:26 -0500
commit3fd9036fc554979e951422a79f0f77f061112bdc (patch)
tree13704c4e6a1d8690fd11ef1f06573c307d18629e /railties/lib
parent55adaa2efc08c892bf7be55d79ac571848068256 (diff)
downloadrails-3fd9036fc554979e951422a79f0f77f061112bdc.tar.gz
rails-3fd9036fc554979e951422a79f0f77f061112bdc.tar.bz2
rails-3fd9036fc554979e951422a79f0f77f061112bdc.zip
Added config.dependency_loading to enable or disable the dependency loader after initialization
Diffstat (limited to 'railties/lib')
-rw-r--r--railties/lib/initializer.rb27
1 files changed, 24 insertions, 3 deletions
diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb
index 97bb81a3c8..44863ab026 100644
--- a/railties/lib/initializer.rb
+++ b/railties/lib/initializer.rb
@@ -171,9 +171,12 @@ module Rails
# Load view path cache
load_view_paths
- # load application classes
+ # Load application classes
load_application_classes
+ # Disable dependency loading during request cycle
+ disable_dependency_loading
+
# Flag initialized
Rails.initialized = true
end
@@ -525,6 +528,12 @@ Run `rake gems:install` to install the missing gems.
Dispatcher.define_dispatcher_callbacks(configuration.cache_classes)
Dispatcher.new(RAILS_DEFAULT_LOGGER).send :run_callbacks, :prepare_dispatch
end
+
+ def disable_dependency_loading
+ if configuration.cache_classes && !configuration.dependency_loading
+ ActiveSupport::Dependencies.unhook!
+ end
+ end
end
# The Configuration class holds all the parameters for the Initializer and
@@ -659,6 +668,17 @@ Run `rake gems:install` to install the missing gems.
!!@reload_plugins
end
+ # Enables or disables dependency loading during the request cycle. Setting
+ # <tt>dependency_loading</tt> to true will allow new classes to be loaded
+ # during a request. Setting it to false will disable this behavior.
+ #
+ # Those who want to run in a threaded environment should disable this
+ # option and eager load or require all there classes on initialization.
+ #
+ # If <tt>cache_classes</tt> is disabled, dependency loaded will always be
+ # on.
+ attr_accessor :dependency_loading
+
# An array of gems that this rails application depends on. Rails will automatically load
# these gems during installation, and allow you to install any missing gems with:
#
@@ -707,6 +727,7 @@ Run `rake gems:install` to install the missing gems.
self.view_path = default_view_path
self.controller_paths = default_controller_paths
self.cache_classes = default_cache_classes
+ self.dependency_loading = default_dependency_loading
self.whiny_nils = default_whiny_nils
self.plugins = default_plugins
self.plugin_paths = default_plugin_paths
@@ -876,8 +897,8 @@ Run `rake gems:install` to install the missing gems.
paths
end
- def default_dependency_mechanism
- :load
+ def default_dependency_loading
+ true
end
def default_cache_classes