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|
|
|
|
|
ActionDispatch::Callbacks.to_prepare(&block)
|
|
|
|
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-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
|
|
|
|
initializer :set_routes_reloader do |app|
|
|
|
|
reloader = lambda { app.routes_reloader.execute_if_updated }
|
|
|
|
reloader.call
|
|
|
|
ActionDispatch::Callbacks.to_prepare(&reloader)
|
|
|
|
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
|