1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #33054 from jboler/master

Fix route eager loading
This commit is contained in:
Rafael França 2018-07-03 14:04:04 -04:00 committed by GitHub
commit cfc48d0b5f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 20 deletions

View file

@ -56,6 +56,7 @@ module ActionDispatch
end
def simulator
return if ast.nil?
@simulator ||= begin
gtg = GTG::Builder.new(ast).transition_table
GTG::Simulator.new(gtg)

View file

@ -127,7 +127,7 @@ module Rails
initializer :set_routes_reloader_hook do |app|
reloader = routes_reloader
reloader.eager_load = app.config.eager_load
reloader.execute_if_updated
reloader.execute
reloaders << reloader
app.reloader.to_run do
# We configure #execute rather than #execute_if_updated because if

View file

@ -7,7 +7,7 @@ module Rails
class RoutesReloader
attr_reader :route_sets, :paths
attr_accessor :eager_load
delegate :updated?, to: :updater
delegate :execute_if_updated, :execute, :updated?, to: :updater
def initialize
@paths = []
@ -19,31 +19,15 @@ module Rails
clear!
load_paths
finalize!
route_sets.each(&:eager_load!) if eager_load
ensure
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
@updater ||= begin
updater = ActiveSupport::FileUpdateChecker.new(paths) { reload! }
updater.execute
updater
end
@updater ||= ActiveSupport::FileUpdateChecker.new(paths) { reload! }
end
def clear!