提交 6f194bb3 编写于 作者: J José Valim

Small tidy up on Rails::Engine.

上级 23a94559
......@@ -288,7 +288,6 @@ def endpoint(endpoint = nil)
end
def namespace(mod)
# TODO: extract that into a module
engine_name(generate_railtie_name(mod))
_railtie = self
......@@ -386,7 +385,7 @@ def config
# per engine and get the engine as a block parameter
initializer :set_autoload_paths, :before => :bootstrap_hook do |app|
ActiveSupport::Dependencies.autoload_paths.unshift(*_all_autoload_paths)
ActiveSupport::Dependencies.autoload_once_paths.unshift(*config.autoload_once_paths)
ActiveSupport::Dependencies.autoload_once_paths.unshift(*_all_autoload_once_paths)
# Freeze so future modifications will fail rather than do nothing mysteriously
config.autoload_paths.freeze
......@@ -419,11 +418,9 @@ def config
initializer :add_view_paths do
views = paths.app.views.to_a
ActiveSupport.on_load(:action_controller) do
prepend_view_path(views)
end
ActiveSupport.on_load(:action_mailer) do
prepend_view_path(views)
unless views.empty?
ActiveSupport.on_load(:action_controller){ prepend_view_path(views) }
ActiveSupport.on_load(:action_mailer){ prepend_view_path(views) }
end
end
......@@ -433,7 +430,7 @@ def config
end
initializer :append_asset_paths do
config.asset_path = "/#{engine_name}%s" unless config.asset_path
config.asset_path ||= "/#{engine_name}%s"
public_path = config.paths.public.to_a.first
if config.compiled_asset_path && File.exist?(public_path)
......@@ -479,6 +476,10 @@ def default_middleware_stack
ActionDispatch::MiddlewareStack.new
end
def _all_autoload_once_paths
config.autoload_once_paths
end
def _all_autoload_paths
@_all_autoload_paths ||= (config.autoload_paths + config.eager_load_paths + config.autoload_once_paths).uniq
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册