Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 90 lines (75 sloc) 2.788 kb
4f03603 @josevalim Break application.rb file in smaller chunks.
josevalim authored
1 module Rails
2 class Application
3 module Finisher
4 include Initializable
8ef1ec4 @arunagw global variable `$rails_rake_task' not initialized Warning removed
arunagw authored
5 $rails_rake_task = nil
4f03603 @josevalim Break application.rb file in smaller chunks.
josevalim authored
6
c2e3ce8 @josevalim Provide a unique point for running initializers.
josevalim authored
7 initializer :load_config_initializers do
8 config.all_initializers.each { |init| load(init) }
9 end
10
6690d66 @josevalim Rename config.cookie_secret to config.secret_token and pass it as config...
josevalim authored
11 initializer :add_generator_templates do
d649bf1 @josevalim Provide a cleaner syntax for paths configuration that does not rely on m...
josevalim authored
12 config.generators.templates.unshift(*paths["lib/templates"].existent)
6690d66 @josevalim Rename config.cookie_secret to config.secret_token and pass it as config...
josevalim authored
13 end
14
6f83a50 @fxn renames load_(once_)paths to autoload_(once_)paths in dependencies and c...
fxn authored
15 initializer :ensure_autoload_once_paths_as_subset do
16 extra = ActiveSupport::Dependencies.autoload_once_paths -
17 ActiveSupport::Dependencies.autoload_paths
924fa08 @josevalim First steps into making Plugin < Engine.
josevalim authored
18
19 unless extra.empty?
20 abort <<-end_error
6f83a50 @fxn renames load_(once_)paths to autoload_(once_)paths in dependencies and c...
fxn authored
21 autoload_once_paths must be a subset of the autoload_paths.
22 Extra items in autoload_once_paths: #{extra * ','}
924fa08 @josevalim First steps into making Plugin < Engine.
josevalim authored
23 end_error
24 end
25 end
26
226d8e7 @josevalim Refactor MetalLoader and RoutesReloader to rely less on class configurat...
josevalim authored
27 initializer :add_builtin_route do |app|
4f03603 @josevalim Break application.rb file in smaller chunks.
josevalim authored
28 if Rails.env.development?
117daba @carllerche Update Rails' built in routes to use RouteSet#append
carllerche authored
29 app.routes.append do
30 match '/rails/info/properties' => "rails/info#properties"
31 end
4f03603 @josevalim Break application.rb file in smaller chunks.
josevalim authored
32 end
33 end
34
e49f94d @josevalim Revert behavior from a5684dfa3c16472bfa5d5d861ba78cb6dbadcb59 and ensure...
josevalim authored
35 initializer :build_middleware_stack do
f816666 @josevalim Alias app to build_middleware_stack for clarity.
josevalim authored
36 build_middleware_stack
e49f94d @josevalim Revert behavior from a5684dfa3c16472bfa5d5d861ba78cb6dbadcb59 and ensure...
josevalim authored
37 end
38
820c0fe @drogus Explicitly define main_app proxy
drogus authored
39 initializer :define_main_app_helper do |app|
40 app.routes.define_mounted_helper(:main_app)
41 end
42
27f0add @josevalim Improve docs for Rails::Application and add routes_reloader_hook and app...
josevalim authored
43 initializer :add_to_prepare_blocks do
44 config.to_prepare_blocks.each do |block|
45 ActionDispatch::Reloader.to_prepare(&block)
46 end
47 end
48
49 # This needs to happen before eager load so it happens
50 # in exactly the same point regardless of config.cache_classes
51 initializer :run_prepare_callbacks do
52 ActionDispatch::Reloader.prepare!
53 end
54
351816f @josevalim Ensure that eager_load actually takes place just after the middleware st...
josevalim authored
55 initializer :eager_load! do
56 if config.cache_classes && !$rails_rake_task
3afdfc3 @josevalim Expose remaining hooks to minimize the need for a Railtie based on feedb...
josevalim authored
57 ActiveSupport.run_load_hooks(:before_eager_load, self)
5a0d73f @josevalim Add lib to load paths when application is inherited to be able to load l...
josevalim authored
58 eager_load!
351816f @josevalim Ensure that eager_load actually takes place just after the middleware st...
josevalim authored
59 end
60 end
61
27f0add @josevalim Improve docs for Rails::Application and add routes_reloader_hook and app...
josevalim authored
62 # All initialization is done, including eager loading in production
351816f @josevalim Ensure that eager_load actually takes place just after the middleware st...
josevalim authored
63 initializer :finisher_hook do
64 ActiveSupport.run_load_hooks(:after_initialize, self)
4f03603 @josevalim Break application.rb file in smaller chunks.
josevalim authored
65 end
66
27f0add @josevalim Improve docs for Rails::Application and add routes_reloader_hook and app...
josevalim authored
67 # Set app reload just after the finisher hook to ensure
68 # paths added in the hook are still loaded.
69 initializer :set_clear_dependencies_hook, :group => :all do |app|
70 ActionDispatch::Reloader.to_cleanup(&app.app_reloader_hook)
71 end
72
73 # Set app reload just after the finisher hook to ensure
74 # routes added in the hook are still loaded.
48bf667 @josevalim Ensure routes are loaded only after the initialization process finishes,...
josevalim authored
75 initializer :set_routes_reloader do |app|
27f0add @josevalim Improve docs for Rails::Application and add routes_reloader_hook and app...
josevalim authored
76 reloader = app.routes_reloader_hook
48bf667 @josevalim Ensure routes are loaded only after the initialization process finishes,...
josevalim authored
77 reloader.call
435bccd Replace AD::Callbacks.to_prepare with AD::Reloader.to_prepare
John Firebaugh authored
78 ActionDispatch::Reloader.to_prepare(&reloader)
48bf667 @josevalim Ensure routes are loaded only after the initialization process finishes,...
josevalim authored
79 end
80
4f03603 @josevalim Break application.rb file in smaller chunks.
josevalim authored
81 # Disable dependency loading during request cycle
5d07869 @josevalim Ensure all initializers are collections.
josevalim authored
82 initializer :disable_dependency_loading do
83 if config.cache_classes && !config.dependency_loading
4f03603 @josevalim Break application.rb file in smaller chunks.
josevalim authored
84 ActiveSupport::Dependencies.unhook!
85 end
86 end
87 end
88 end
f38e89c @josh Move railties/builtin into lib
josh authored
89 end
Something went wrong with that request. Please try again.