Permalink
Browse files

Moved Rails::RoutesReloader to Rails::Application::RoutesReloader

  • Loading branch information...
drogus committed Sep 29, 2010
1 parent 6648bab commit 3049e645e5037cd923d0bad3c41c105dd9d791f8
@@ -1,7 +1,6 @@
require 'active_support/core_ext/hash/reverse_merge'
require 'active_support/file_update_checker'
require 'fileutils'
-require 'rails/routes_reloader'
require 'rails/plugin'
require 'rails/engine'
@@ -40,6 +39,7 @@ class Application < Engine
autoload :Configuration, 'rails/application/configuration'
autoload :Finisher, 'rails/application/finisher'
autoload :Railties, 'rails/application/railties'
+ autoload :RoutesReloader, 'rails/application/routes_reloader'
class << self
def inherited(base)
@@ -82,7 +82,7 @@ def eager_load! #:nodoc:
end
def routes_reloader
- @routes_reloader ||= Rails::RoutesReloader.new
+ @routes_reloader ||= RoutesReloader.new
end
def initialize!
@@ -0,0 +1,55 @@
+module Rails
+ class Application
+ class RoutesReloader < ::ActiveSupport::FileUpdateChecker
+ def initialize
+ super([]) { reload! }
+ end
+
+ def blocks
+ @blocks ||= {}
+ end
+ private
+ def reload!
+ clear!
+ load_blocks
+ load_paths
+ finalize!
+ ensure
+ revert
+ end
+
+ def clear!
+ routers.each do |routes|
+ routes.disable_clear_and_finalize = true
+ routes.clear!
+ end
+ end
+
+ def load_blocks
+ blocks.each do |routes, block|
+ routes.draw(&block) if block
+ end
+ end
+
+ def load_paths
+ paths.each { |path| load(path) }
+ end
+
+ def finalize!
+ routers.each do |routes|
+ ActiveSupport.on_load(:action_controller) { routes.finalize! }
+ end
+ end
+
+ def revert
+ routers.each do |routes|
+ routes.disable_clear_and_finalize = false
+ end
+ end
+
+ def routers
+ blocks.keys
+ end
+ end
+ end
+end
@@ -1,54 +0,0 @@
-module Rails
- class RoutesReloader < ::ActiveSupport::FileUpdateChecker
- def initialize
- super([]) { reload! }
- end
-
- def blocks
- @blocks ||= {}
- end
- private
- def reload!
- clear!
- load_blocks
- load_paths
- finalize!
- ensure
- revert
- end
-
- def clear!
- routers.each do |routes|
- routes.disable_clear_and_finalize = true
- routes.clear!
- end
- end
-
- def load_blocks
- blocks.each do |routes, block|
- routes.draw(&block) if block
- end
- end
-
- def load_paths
- paths.each { |path| load(path) }
- end
-
- def finalize!
- routers.each do |routes|
- ActiveSupport.on_load(:action_controller) { routes.finalize! }
- end
- end
-
- def revert
- routers.each do |routes|
- routes.disable_clear_and_finalize = false
- end
- end
-
- def routers
- blocks.keys
- end
- end
-end
-

0 comments on commit 3049e64

Please sign in to comment.