aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/engine.rb
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2010-05-15 23:48:56 +0200
committerJosé Valim <jose.valim@gmail.com>2010-05-15 23:49:03 +0200
commit351816fab6dbe564b7bddbd877648edb06a2bfb1 (patch)
treef55bca0e7832923efd56d9acc681bc0952b54c32 /railties/lib/rails/engine.rb
parent6617d0189377a2f820c8f948589bb2d4a91155af (diff)
downloadrails-351816fab6dbe564b7bddbd877648edb06a2bfb1.tar.gz
rails-351816fab6dbe564b7bddbd877648edb06a2bfb1.tar.bz2
rails-351816fab6dbe564b7bddbd877648edb06a2bfb1.zip
Ensure that eager_load actually takes place just after the middleware stack is built by using another pattern.
Also create a engine_blank_point initializer to ensure any :before or :after hooks defined inside engines won't move the configuration initializers to other places.
Diffstat (limited to 'railties/lib/rails/engine.rb')
-rw-r--r--railties/lib/rails/engine.rb25
1 files changed, 12 insertions, 13 deletions
diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb
index 652bd40ee4..b44755820c 100644
--- a/railties/lib/rails/engine.rb
+++ b/railties/lib/rails/engine.rb
@@ -132,6 +132,15 @@ module Rails
config.paths.lib.tasks.to_a.sort.each { |ext| load(ext) }
end
+ def eager_load!
+ config.eager_load_paths.each do |load_path|
+ matcher = /\A#{Regexp.escape(load_path)}\/(.*)\.rb\Z/
+ Dir.glob("#{load_path}/**/*.rb").sort.each do |file|
+ require_dependency file.sub(matcher, '\1')
+ end
+ end
+ end
+
# Add configured load paths to ruby load paths and remove duplicates.
initializer :set_load_path, :before => :bootstrap_hook do
config.load_paths.reverse_each do |path|
@@ -203,19 +212,9 @@ module Rails
end
end
- # This needs to be an initializer, since it needs to run once
- # per engine and get the engine as a block parameter
- initializer :load_app_classes, :before => :finisher_hook do |app|
- next if $rails_rake_task
-
- if app.config.cache_classes
- config.eager_load_paths.each do |load_path|
- matcher = /\A#{Regexp.escape(load_path)}\/(.*)\.rb\Z/
- Dir.glob("#{load_path}/**/*.rb").sort.each do |file|
- require_dependency file.sub(matcher, '\1')
- end
- end
- end
+ initializer :engines_blank_point do
+ # We need this initializer so all extra initializers added in engines are
+ # consistently executed after all the initializers above across all engines.
end
protected