Class: Rack::Insight::PanelsContent

Inherits:
PanelApp
  • Object
show all
Defined in:
lib/rack/insight/panels-content.rb

Instance Attribute Summary

Attributes inherited from PanelApp

#request

Instance Method Summary collapse

Methods inherited from PanelApp

#call, #not_found, #params, #render_template, #validate_params

Methods included from Render

#compile, #compile!, #compiled_source, #method_name, #method_name_without_locals, #render_template, #signed_params

Methods included from Logging

logger, verbose, verbosity

Constructor Details

#initialize(insight_app) ⇒ PanelsContent

Returns a new instance of PanelsContent.



3
4
5
6
# File 'lib/rack/insight/panels-content.rb', line 3

def initialize(insight_app)
  @insight_app = insight_app
  @request_table = Database::RequestTable.new
end

Instance Method Details

#dispatchObject



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/rack/insight/panels-content.rb', line 8

def dispatch
  return not_found("not get") unless @request.get?
  return not_found("id nil") if params['request_id'].nil?
  request = @request_table.select("*", "id = #{params['request_id']}").first
  return not_found("id not found") if request.nil?
  requests = @request_table.to_a.map do |row|
    { :id => row[0], :method => row[1], :path => row[2] }
  end
  render_template("request_fragment",
                  :request_id => params['request_id'].to_i,
                  :requests => requests,
                  :panels => @insight_app.panels)
end