diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2017-01-30 21:51:09 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-30 21:51:09 -0500 |
commit | ce97c79445f9ac4b056e34deaaaaf25cadc08b72 (patch) | |
tree | 03ef116200ec06a867fd6ca9b144483d769e2a0d /railties/lib/rails/application | |
parent | 543f19626b80e72c543306b6ca67421df3a42d6c (diff) | |
parent | 5b1332bb4d3c3aa5215b43004d1e7f6a8d376dd0 (diff) | |
download | rails-ce97c79445f9ac4b056e34deaaaaf25cadc08b72.tar.gz rails-ce97c79445f9ac4b056e34deaaaaf25cadc08b72.tar.bz2 rails-ce97c79445f9ac4b056e34deaaaaf25cadc08b72.zip |
Merge pull request #27647 from Shopify/fully-eagerload-journey
Fully initialize routes before the first request is handled
Diffstat (limited to 'railties/lib/rails/application')
-rw-r--r-- | railties/lib/rails/application/finisher.rb | 1 | ||||
-rw-r--r-- | railties/lib/rails/application/routes_reloader.rb | 17 |
2 files changed, 17 insertions, 1 deletions
diff --git a/railties/lib/rails/application/finisher.rb b/railties/lib/rails/application/finisher.rb index a855e8fab0..c027d06663 100644 --- a/railties/lib/rails/application/finisher.rb +++ b/railties/lib/rails/application/finisher.rb @@ -124,6 +124,7 @@ module Rails # the hook are taken into account. initializer :set_routes_reloader_hook do |app| reloader = routes_reloader + reloader.eager_load = app.config.eager_load reloader.execute_if_updated reloaders << reloader app.reloader.to_run do diff --git a/railties/lib/rails/application/routes_reloader.rb b/railties/lib/rails/application/routes_reloader.rb index cf0a4e128f..e02ef629f2 100644 --- a/railties/lib/rails/application/routes_reloader.rb +++ b/railties/lib/rails/application/routes_reloader.rb @@ -4,11 +4,13 @@ module Rails class Application class RoutesReloader attr_reader :route_sets, :paths - delegate :execute_if_updated, :execute, :updated?, to: :updater + attr_accessor :eager_load + delegate :updated?, to: :updater def initialize @paths = [] @route_sets = [] + @eager_load = false end def reload! @@ -19,6 +21,19 @@ module Rails revert end + def execute + ret = updater.execute + route_sets.each(&:eager_load!) if eager_load + ret + end + + def execute_if_updated + if updated = updater.execute_if_updated + route_sets.each(&:eager_load!) if eager_load + end + updated + end + private def updater |