aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2007-09-18 01:45:37 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2007-09-18 01:45:37 +0000
commit4f375d5b82705db9aeb652d2a562c2df369ca4ac (patch)
tree2116aa44da9132742498c0cd167985fa8c67f359 /railties/lib
parent71e33d96509d0a8fe698b228579e5a7adef48601 (diff)
downloadrails-4f375d5b82705db9aeb652d2a562c2df369ca4ac.tar.gz
rails-4f375d5b82705db9aeb652d2a562c2df369ca4ac.tar.bz2
rails-4f375d5b82705db9aeb652d2a562c2df369ca4ac.zip
Support multiple config.after_initialize blocks so plugins and apps can more easily cooperate. Closes #9582.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7507 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties/lib')
-rw-r--r--railties/lib/initializer.rb14
1 files changed, 8 insertions, 6 deletions
diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb
index d55352d6a2..4339c4b996 100644
--- a/railties/lib/initializer.rb
+++ b/railties/lib/initializer.rb
@@ -325,7 +325,9 @@ module Rails
# Fires the user-supplied after_initialize block (Configuration#after_initialize)
def after_initialize
- configuration.after_initialize_block.call if configuration.after_initialize_block
+ configuration.after_initialize_blocks.each do |block|
+ block.call
+ end
end
def load_application_initializers
@@ -515,16 +517,16 @@ module Rails
::RAILS_ENV
end
- # Sets a block which will be executed after rails has been fully initialized.
+ # Adds 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
+ after_initialize_blocks << after_initialize_block if after_initialize_block
end
- # Returns the block set in Configuration#after_initialize
- def after_initialize_block
- @after_initialize_block
+ # Returns the blocks added with Configuration#after_initialize
+ def after_initialize_blocks
+ @after_initialize_blocks ||= []
end
# Add a preparation callback that will run before every request in development