aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/engine.rb
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2010-06-28 00:57:47 +0200
committerJosé Valim <jose.valim@gmail.com>2010-06-28 01:22:32 +0200
commit9b19a6f16cebf4257d2f0b839f6cc8ff5db5c47b (patch)
tree98028044107a83c44f658e077a587c65d27d31b3 /railties/lib/rails/engine.rb
parent4329f8133fee8e4f3e558787f67de59f0c4a4dd1 (diff)
downloadrails-9b19a6f16cebf4257d2f0b839f6cc8ff5db5c47b.tar.gz
rails-9b19a6f16cebf4257d2f0b839f6cc8ff5db5c47b.tar.bz2
rails-9b19a6f16cebf4257d2f0b839f6cc8ff5db5c47b.zip
A few changes were done in this commit:
* Added :autoload to engines path API and redefine usage to be in sync with 6f83a5036d8a9c3f8ed7; * Do not autoload code in *lib* for applications (now you need to explicitly require them). This makes an application behave closer to an engine (code in lib is still autoloaded for plugins); * Always autoload code in app/ for engines and plugins. This makes engines behave closer to an application and should allow us to get rid of the unloadable hack required when controllers inside engines inherit from ApplicationController;
Diffstat (limited to 'railties/lib/rails/engine.rb')
-rw-r--r--railties/lib/rails/engine.rb21
1 files changed, 10 insertions, 11 deletions
diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb
index 0a3f21fb1b..ee3e3ba040 100644
--- a/railties/lib/rails/engine.rb
+++ b/railties/lib/rails/engine.rb
@@ -142,7 +142,7 @@ module Rails
# Add configured load paths to ruby load paths and remove duplicates.
initializer :set_load_path, :before => :bootstrap_hook do
- config.autoload_paths.reverse_each do |path|
+ _all_load_paths.reverse_each do |path|
$LOAD_PATH.unshift(path) if File.directory?(path)
end
$LOAD_PATH.uniq!
@@ -154,16 +154,12 @@ module Rails
# This needs to be an initializer, since it needs to run once
# per engine and get the engine as a block parameter
initializer :set_autoload_paths, :before => :bootstrap_hook do |app|
- ActiveSupport::Dependencies.autoload_paths.unshift(*config.autoload_paths)
-
- if reloadable?(app)
- ActiveSupport::Dependencies.autoload_once_paths.unshift(*config.autoload_once_paths)
- else
- ActiveSupport::Dependencies.autoload_once_paths.unshift(*config.autoload_paths)
- end
+ ActiveSupport::Dependencies.autoload_paths.unshift(*_all_autoload_paths)
+ ActiveSupport::Dependencies.autoload_once_paths.unshift(*config.autoload_once_paths)
# Freeze so future modifications will fail rather than do nothing mysteriously
config.autoload_paths.freeze
+ config.eager_load_paths.freeze
config.autoload_once_paths.freeze
end
@@ -195,7 +191,6 @@ module Rails
ActiveSupport.on_load(:action_controller) do
prepend_view_path(views)
end
-
ActiveSupport.on_load(:action_mailer) do
prepend_view_path(views)
end
@@ -214,8 +209,12 @@ module Rails
protected
- def reloadable?(app)
- app.config.reload_engines
+ def _all_autoload_paths
+ @_all_autoload_paths ||= (config.autoload_paths + config.eager_load_paths + config.autoload_once_paths).uniq
+ end
+
+ def _all_load_paths
+ @_all_load_paths ||= (config.paths.load_paths + _all_autoload_paths).uniq
end
end
end