Class: ActionDispatch::Routing::HtmlTableFormatter

Inherits:
Object
  • Object
show all
Defined in:
actionpack/lib/action_dispatch/routing/inspector.rb

Instance Method Summary collapse

Constructor Details

#initialize(view) ⇒ HtmlTableFormatter

Returns a new instance of HtmlTableFormatter.



188
189
190
191
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 188

def initialize(view)
  @view = view
  @buffer = []
end

Instance Method Details

#header(routes) ⇒ Object

The header is part of the HTML page, so we don’t construct it here.



202
203
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 202

def header(routes)
end

#no_routesObject



205
206
207
208
209
210
211
212
213
214
215
216
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 205

def no_routes(*)
  @buffer << "    <p>You don't have any routes defined!</p>\n    <ul>\n      <li>Please add some routes in <tt>config/routes.rb</tt>.</li>\n      <li>\n        For more information about routes, please see the Quails guide\n        <a href=\"http://guides.rubyonquails.org/routing.html\">Quails Routing from the Outside In</a>.\n      </li>\n    </ul>\n    MESSAGE\nend\n".strip_heredoc

#resultObject



218
219
220
221
222
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 218

def result
  @view.raw @view.render(layout: "routes/table") {
    @view.raw @buffer.join("\n")
  }
end

#section(routes) ⇒ Object



197
198
199
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 197

def section(routes)
  @buffer << @view.render(partial: "routes/route", collection: routes)
end

#section_title(title) ⇒ Object



193
194
195
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 193

def section_title(title)
  @buffer << %(<tr><th colspan="4">#{title}</th></tr>)
end