Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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