提交 49fad6e6 编写于 作者: M Michael Koziarski

Add Configuration#after_initialize for specifying a block to be executed after...

Add Configuration#after_initialize for specifying a block to be executed after the framework is completely initialized.


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3547 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 7139e2a0
*SVN* *SVN*
* Added Configuration#after_initialize for registering a block which gets called after the framework is fully initialized. Useful for things like per-environment configuration of plugins. [Michael Koziarski]
* Added check for RAILS_FRAMEWORK_ROOT constant that allows the Rails framework to be found in a different place than vendor/rails. Should be set in boot.rb. [DHH] * Added check for RAILS_FRAMEWORK_ROOT constant that allows the Rails framework to be found in a different place than vendor/rails. Should be set in boot.rb. [DHH]
* Fixed that static requests could unlock the mutex guarding dynamic requests in the WEBrick servlet #3433 [tom@craz8.com] * Fixed that static requests could unlock the mutex guarding dynamic requests in the WEBrick servlet #3433 [tom@craz8.com]
......
...@@ -101,6 +101,9 @@ def process ...@@ -101,6 +101,9 @@ def process
# Routing must be initialized after plugins to allow the former to extend the routes # Routing must be initialized after plugins to allow the former to extend the routes
initialize_routing initialize_routing
# the framework is now fully initialized
after_initialize
end end
# Set the <tt>$LOAD_PATH</tt> based on the value of # Set the <tt>$LOAD_PATH</tt> based on the value of
...@@ -245,7 +248,7 @@ def initialize_whiny_nils ...@@ -245,7 +248,7 @@ def initialize_whiny_nils
require('active_support/whiny_nil') if configuration.whiny_nils require('active_support/whiny_nil') if configuration.whiny_nils
end end
# Initialize framework-specific settings for each of the loaded frameworks # Initializes framework-specific settings for each of the loaded frameworks
# (Configuration#frameworks). The available settings map to the accessors # (Configuration#frameworks). The available settings map to the accessors
# on each of the corresponding Base classes. # on each of the corresponding Base classes.
def initialize_framework_settings def initialize_framework_settings
...@@ -257,6 +260,12 @@ def initialize_framework_settings ...@@ -257,6 +260,12 @@ def initialize_framework_settings
end end
end end
end end
# Fires the user-supplied after_initialize block (Configuration#after_initialize)
def after_initialize
configuration.after_initialize_block.call if configuration.after_initialize_block
end
protected protected
# Return a list of plugin paths within base_path. A plugin path is # Return a list of plugin paths within base_path. A plugin path is
...@@ -440,7 +449,19 @@ def environment_path ...@@ -440,7 +449,19 @@ def environment_path
def environment def environment
::RAILS_ENV ::RAILS_ENV
end end
# Sets a block which will be executed after rails has been fully initialized.
# Useful for per-environment configuration which depends on the framework being
# fully initialized.
def after_initialize(&after_initialize_block)
@after_initialize_block = after_initialize_block
end
# Returns the block set in Configuration#after_initialize
def after_initialize_block
@after_initialize_block
end
private private
def root_path def root_path
::RAILS_ROOT ::RAILS_ROOT
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册