aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorKasper Timm Hansen <kaspth@gmail.com>2018-03-13 20:21:54 +0100
committerKasper Timm Hansen <kaspth@gmail.com>2018-03-13 20:22:23 +0100
commitf6310a3f163d565cfc014143212e5ee2f0f2ae79 (patch)
treea1de2130bac0669bb51435dc7315f710359ed2f0 /railties
parentba0ae542cabe573be11b1177b2095973c11a7aac (diff)
downloadrails-f6310a3f163d565cfc014143212e5ee2f0f2ae79.tar.gz
rails-f6310a3f163d565cfc014143212e5ee2f0f2ae79.tar.bz2
rails-f6310a3f163d565cfc014143212e5ee2f0f2ae79.zip
Extract details to methods to clarify command.
Diffstat (limited to 'railties')
-rw-r--r--railties/lib/rails/commands/routes/routes_command.rb20
1 files changed, 12 insertions, 8 deletions
diff --git a/railties/lib/rails/commands/routes/routes_command.rb b/railties/lib/rails/commands/routes/routes_command.rb
index 25ee65aeaa..41162a4425 100644
--- a/railties/lib/rails/commands/routes/routes_command.rb
+++ b/railties/lib/rails/commands/routes/routes_command.rb
@@ -23,17 +23,21 @@ module Rails
require_application_and_environment!
require "action_dispatch/routing/inspector"
- all_routes = Rails.application.routes.routes
- inspector = ActionDispatch::Routing::RoutesInspector.new(all_routes)
-
- if options.has_key?("expanded_format")
- say inspector.format(ActionDispatch::Routing::ConsoleFormatter::Expanded.new, routes_filter)
- else
- say inspector.format(ActionDispatch::Routing::ConsoleFormatter::Sheet.new, routes_filter)
- end
+ say inspector.format(formatter, routes_filter)
end
private
+ def inspector
+ ActionDispatch::Routing::RoutesInspector.new(Rails.application.routes.routes)
+ end
+
+ def formatter
+ if options.key?("expanded_format")
+ ActionDispatch::Routing::ConsoleFormatter::Expanded.new
+ else
+ ActionDispatch::Routing::ConsoleFormatter::Sheet.new
+ end
+ end
def routes_filter
options.symbolize_keys.slice(:controller, :grep_pattern)