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