aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib
diff options
context:
space:
mode:
authorMichael Koziarski <michael@koziarski.com>2006-02-07 00:21:45 +0000
committerMichael Koziarski <michael@koziarski.com>2006-02-07 00:21:45 +0000
commit49fad6e6d5171e632086d7f7491ef14c8a04e4cc (patch)
treeb1674e0ff6eb9a00aee7894f6f12b67052657c40 /railties/lib
parent7139e2a0e1c24788758ccd6131ba86243de84bf6 (diff)
downloadrails-49fad6e6d5171e632086d7f7491ef14c8a04e4cc.tar.gz
rails-49fad6e6d5171e632086d7f7491ef14c8a04e4cc.tar.bz2
rails-49fad6e6d5171e632086d7f7491ef14c8a04e4cc.zip
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
Diffstat (limited to 'railties/lib')
-rw-r--r--railties/lib/initializer.rb25
1 files changed, 23 insertions, 2 deletions
diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb
index e1b058f3b9..9550d6d583 100644
--- a/railties/lib/initializer.rb
+++ b/railties/lib/initializer.rb
@@ -101,6 +101,9 @@ module Rails
# Routing must be initialized after plugins to allow the former to extend the routes
initialize_routing
+
+ # the framework is now fully initialized
+ after_initialize
end
# Set the <tt>$LOAD_PATH</tt> based on the value of
@@ -245,7 +248,7 @@ module Rails
require('active_support/whiny_nil') if configuration.whiny_nils
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
# on each of the corresponding Base classes.
def initialize_framework_settings
@@ -257,6 +260,12 @@ module Rails
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
# Return a list of plugin paths within base_path. A plugin path is
@@ -440,7 +449,19 @@ module Rails
def environment
::RAILS_ENV
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
def root_path
::RAILS_ROOT