class Quails::Application::RoutesReloader

Attributes

eager_load[RW]
paths[R]
route_sets[R]

Public Class Methods

new() click to toggle source
# File railties/lib/rails/application/routes_reloader.rb, line 12
def initialize
  @paths      = []
  @route_sets = []
  @eager_load = false
end

Public Instance Methods

execute() click to toggle source
# File railties/lib/rails/application/routes_reloader.rb, line 26
def execute
  ret = updater.execute
  route_sets.each(&:eager_load!) if eager_load
  ret
end
execute_if_updated() click to toggle source
# File railties/lib/rails/application/routes_reloader.rb, line 32
def execute_if_updated
  if updated = updater.execute_if_updated
    route_sets.each(&:eager_load!) if eager_load
  end
  updated
end
reload!() click to toggle source
# File railties/lib/rails/application/routes_reloader.rb, line 18
def reload!
  clear!
  load_paths
  finalize!
ensure
  revert
end

Private Instance Methods

clear!() click to toggle source
# File railties/lib/rails/application/routes_reloader.rb, line 49
def clear!
  route_sets.each do |routes|
    routes.disable_clear_and_finalize = true
    routes.clear!
  end
end
finalize!() click to toggle source
# File railties/lib/rails/application/routes_reloader.rb, line 60
def finalize!
  route_sets.each(&:finalize!)
end
load_paths() click to toggle source
# File railties/lib/rails/application/routes_reloader.rb, line 56
def load_paths
  paths.each { |path| load(path) }
end
revert() click to toggle source
# File railties/lib/rails/application/routes_reloader.rb, line 64
def revert
  route_sets.each do |routes|
    routes.disable_clear_and_finalize = false
  end
end
updater() click to toggle source
# File railties/lib/rails/application/routes_reloader.rb, line 41
def updater
  @updater ||= begin
    updater = ActiveSupport::FileUpdateChecker.new(paths) { reload! }
    updater.execute
    updater
  end
end