Sha256: e47d54b4f3e29a89c74a6f3a4ce58585d2f8346a7d5b2c8a8ca8c1291bb4846f

Contents?: true

Size: 1.06 KB

Versions: 126

Compression:

Stored size: 1.06 KB

Contents

require "active_support/core_ext/module/delegation"

module Rails
  class Application
    class RoutesReloader
      attr_reader :route_sets, :paths
      delegate :execute_if_updated, :execute, :updated?, to: :updater

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

      def reload!
        clear!
        load_paths
        finalize!
      ensure
        revert
      end

    private

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

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

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

      def finalize!
        route_sets.each do |routes|
          routes.finalize!
        end
      end

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

Version data entries

126 entries across 122 versions & 10 rubygems

Version Path
railties-4.2.11.3 lib/rails/application/routes_reloader.rb
railties-4.2.11.2 lib/rails/application/routes_reloader.rb
railties-4.2.11.1 lib/rails/application/routes_reloader.rb
railties-4.2.11 lib/rails/application/routes_reloader.rb
railties-4.2.10 lib/rails/application/routes_reloader.rb
railties-4.2.10.rc1 lib/rails/application/routes_reloader.rb
railties-4.2.9 lib/rails/application/routes_reloader.rb
railties-4.2.9.rc2 lib/rails/application/routes_reloader.rb
railties-4.2.9.rc1 lib/rails/application/routes_reloader.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/railties-4.2.8/lib/rails/application/routes_reloader.rb
railties-4.2.8 lib/rails/application/routes_reloader.rb
railties-4.2.8.rc1 lib/rails/application/routes_reloader.rb
railties-4.2.7.1 lib/rails/application/routes_reloader.rb
railties-4.2.7 lib/rails/application/routes_reloader.rb
railties-4.1.16 lib/rails/application/routes_reloader.rb
railties-4.1.16.rc1 lib/rails/application/routes_reloader.rb
railties-4.2.7.rc1 lib/rails/application/routes_reloader.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/railties-4.2.6/lib/rails/application/routes_reloader.rb
railties-4.1.15 lib/rails/application/routes_reloader.rb
railties-4.2.6 lib/rails/application/routes_reloader.rb