2010-01-23 15:07:20 +00:00
|
|
|
module Rails
|
|
|
|
class Application
|
|
|
|
module Finisher
|
|
|
|
include Initializable
|
|
|
|
|
2010-04-05 08:52:47 +00:00
|
|
|
initializer :add_generator_templates do
|
2010-10-06 15:18:59 +00:00
|
|
|
config.generators.templates.unshift(*paths["lib/templates"].existent)
|
2010-04-05 08:52:47 +00:00
|
|
|
end
|
|
|
|
|
2010-06-22 21:17:20 +00:00
|
|
|
initializer :ensure_autoload_once_paths_as_subset do
|
|
|
|
extra = ActiveSupport::Dependencies.autoload_once_paths -
|
|
|
|
ActiveSupport::Dependencies.autoload_paths
|
2010-01-23 16:13:25 +00:00
|
|
|
|
|
|
|
unless extra.empty?
|
|
|
|
abort <<-end_error
|
2010-06-22 21:17:20 +00:00
|
|
|
autoload_once_paths must be a subset of the autoload_paths.
|
|
|
|
Extra items in autoload_once_paths: #{extra * ','}
|
2010-01-23 16:13:25 +00:00
|
|
|
end_error
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-01-27 16:46:55 +00:00
|
|
|
initializer :add_to_prepare_blocks do
|
|
|
|
config.to_prepare_blocks.each do |block|
|
2010-12-19 23:58:58 +00:00
|
|
|
ActionDispatch::Reloader.to_prepare(&block)
|
2010-01-27 16:46:55 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-01-27 16:39:35 +00:00
|
|
|
initializer :add_builtin_route do |app|
|
2010-01-23 15:07:20 +00:00
|
|
|
if Rails.env.development?
|
2010-09-17 19:27:48 +00:00
|
|
|
app.routes.append do
|
|
|
|
match '/rails/info/properties' => "rails/info#properties"
|
|
|
|
end
|
2010-01-23 15:07:20 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-02-19 07:02:28 +00:00
|
|
|
initializer :build_middleware_stack do
|
2010-06-20 23:08:50 +00:00
|
|
|
build_middleware_stack
|
2010-02-19 07:02:28 +00:00
|
|
|
end
|
|
|
|
|
2010-12-19 23:58:58 +00:00
|
|
|
initializer :run_prepare_callbacks do
|
|
|
|
ActionDispatch::Reloader.prepare!
|
|
|
|
end
|
|
|
|
|
2011-04-25 12:56:58 +00:00
|
|
|
initializer :define_main_app_helper do |app|
|
|
|
|
app.routes.define_mounted_helper(:main_app)
|
|
|
|
end
|
|
|
|
|
2010-05-15 21:48:56 +00:00
|
|
|
initializer :eager_load! do
|
|
|
|
if config.cache_classes && !$rails_rake_task
|
2010-05-15 22:34:54 +00:00
|
|
|
ActiveSupport.run_load_hooks(:before_eager_load, self)
|
2010-06-01 22:42:20 +00:00
|
|
|
eager_load!
|
2010-05-15 21:48:56 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
initializer :finisher_hook do
|
|
|
|
ActiveSupport.run_load_hooks(:after_initialize, self)
|
2010-01-23 15:07:20 +00:00
|
|
|
end
|
|
|
|
|
2010-09-02 10:54:16 +00:00
|
|
|
# Force routes to be loaded just at the end and add it to to_prepare callbacks
|
2011-04-17 08:51:07 +00:00
|
|
|
# This needs to be after the finisher hook to ensure routes added in the hook
|
|
|
|
# are still loaded.
|
2010-09-02 10:54:16 +00:00
|
|
|
initializer :set_routes_reloader do |app|
|
|
|
|
reloader = lambda { app.routes_reloader.execute_if_updated }
|
|
|
|
reloader.call
|
2010-12-19 23:58:58 +00:00
|
|
|
ActionDispatch::Reloader.to_prepare(&reloader)
|
2010-09-02 10:54:16 +00:00
|
|
|
end
|
|
|
|
|
2010-01-23 15:07:20 +00:00
|
|
|
# Disable dependency loading during request cycle
|
2010-01-25 23:08:08 +00:00
|
|
|
initializer :disable_dependency_loading do
|
|
|
|
if config.cache_classes && !config.dependency_loading
|
2010-01-23 15:07:20 +00:00
|
|
|
ActiveSupport::Dependencies.unhook!
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2010-03-20 17:34:21 +00:00
|
|
|
end
|