class Rails::Application::RoutesReloader

def clear!

def clear!
  route_sets.each do |routes|
    routes.disable_clear_and_finalize = true
    routes.clear!
  end
end

def finalize!

def finalize!
  route_sets.each do |routes|
    ActiveSupport.on_load(:action_controller) { routes.finalize! }
  end
end

def initialize

def initialize
  @paths      = []
  @route_sets = []
end

def load_paths

def load_paths
  paths.each { |path| load(path) }
end

def reload!

def reload!
  clear!
  load_paths
  finalize!
ensure
  revert
end

def revert

def revert
  route_sets.each do |routes|
    routes.disable_clear_and_finalize = false
  end
end

def updater

def updater
  @updater ||= begin
    updater = ActiveSupport::FileUpdateChecker.new(paths) { reload! }
    updater.execute
    updater
  end
end