class ActionDispatch::Routing::JsonFormatter
ActionDispatch::Routing
JSON formatter
This class can be used as formatter for ActionDispatch::Routing::RoutesInspector#format(), and produce a valid JSON with the routing data for the Rails application.
Public Class Methods
new()
click to toggle source
# File lib/action_dispatch/routing/json_formatter.rb, line 10 def initialize @buffer = [] end
Public Instance Methods
header(routes)
click to toggle source
# File lib/action_dispatch/routing/json_formatter.rb, line 26 def header(routes) @buffer << '' end
no_routes()
click to toggle source
# File lib/action_dispatch/routing/json_formatter.rb, line 30 def no_routes @buffer << JSON.generate({ routes: [] }) end
result()
click to toggle source
# File lib/action_dispatch/routing/json_formatter.rb, line 14 def result @buffer.join("\n") end
section(routes)
click to toggle source
# File lib/action_dispatch/routing/json_formatter.rb, line 22 def section(routes) @buffer << JSON.generate({ routes: routes }) end
section_title(title)
click to toggle source
# File lib/action_dispatch/routing/json_formatter.rb, line 18 def section_title(title) @buffer << "" end