diff options
Diffstat (limited to 'railties/lib/rails/application/routes_reloader.rb')
-rw-r--r-- | railties/lib/rails/application/routes_reloader.rb | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/railties/lib/rails/application/routes_reloader.rb b/railties/lib/rails/application/routes_reloader.rb index 1d1f5e1b06..19f616ec50 100644 --- a/railties/lib/rails/application/routes_reloader.rb +++ b/railties/lib/rails/application/routes_reloader.rb @@ -1,11 +1,15 @@ +require "active_support/core_ext/module/delegation" + module Rails class Application - class RoutesReloader < ::ActiveSupport::FileUpdateChecker - attr_reader :route_sets + class RoutesReloader + attr_reader :route_sets, :paths, :external_routes + delegate :execute_if_updated, :execute, :updated?, :to => :updater def initialize - super([]) { reload! } - @route_sets = [] + @paths = [] + @route_sets = [] + @external_routes = [] end def reload! @@ -16,7 +20,19 @@ module Rails revert end - protected + private + + def updater + @updater ||= begin + dirs = @external_routes.each_with_object({}) do |dir, hash| + hash[dir.to_s] = %w(rb) + end + + updater = ActiveSupport::FileUpdateChecker.new(paths, dirs) { reload! } + updater.execute + updater + end + end def clear! route_sets.each do |routes| @@ -31,7 +47,7 @@ module Rails def finalize! route_sets.each do |routes| - ActiveSupport.on_load(:action_controller) { routes.finalize! } + routes.finalize! end end |