Class: Insight::Panel
Overview
Panels are also Rack middleware
Direct Known Subclasses
ActiveRecordPanel, ActiveResourcePanel, CachePanel, LogPanel, MemoryPanel, RailsInfoPanel, RedisPanel, RequestVariablesPanel, SQLPanel, SpeedTracer::Panel, TemplatesPanel, TimerPanel
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#after_detect, #before_detect, #probe, #request_finish, #request_start
Methods included from Logging
logger
#key_sql_template, #retrieve, #store, #table_length, #table_setup
Methods included from Render
#compile, #compile!, #compiled_source, #method_name, #method_name_without_locals, #render_template, #signed_params
Constructor Details
#initialize(app) ⇒ Panel
Returns a new instance of Panel.
65
66
67
68
69
70
71
72
|
# File 'lib/insight/panel.rb', line 65
def initialize(app)
if panel_app
@app = Rack::Cascade.new([panel_app, app])
else
@app = app
end
end
|
Instance Attribute Details
#request ⇒ Object
Returns the value of attribute request.
16
17
18
|
# File 'lib/insight/panel.rb', line 16
def request
@request
end
|
Class Method Details
.current_panel_file ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/insight/panel.rb', line 37
def current_panel_file
return Thread::current['panel_file'] ||
begin
file_name = nil
caller.each do |line|
md = %r{^[^:]*insight/panels/([^:]*)\.rb:}.match line
unless md.nil?
file_name = md[1]
end
end
file_name
end
end
|
.excluded(klass = nil) ⇒ Object
59
60
61
|
# File 'lib/insight/panel.rb', line 59
def excluded(klass = nil)
Panel::panel_exclusion << klass || self
end
|
.file_index ⇒ Object
19
20
21
22
23
|
# File 'lib/insight/panel.rb', line 19
def file_index
return @file_index ||= Hash.new do |h,k|
h[k] = []
end
end
|
.from_file(rel_path) ⇒ Object
29
30
31
32
33
34
35
|
# File 'lib/insight/panel.rb', line 29
def from_file(rel_path)
old_rel, Thread::current['panel_file'] = Thread::current['panel_file'], rel_path
require File::join('insight', 'panels', rel_path)
return (file_index[rel_path] - panel_exclusion)
ensure
Thread::current['panel_file'] = old_rel
end
|
.inherited(sub) ⇒ Object
51
52
53
54
55
56
57
|
# File 'lib/insight/panel.rb', line 51
def inherited(sub)
if filename = current_panel_file
Panel::file_index[current_panel_file] << sub
else
warn "Insight::Panel inherited by #{sub.name} outside of an insight/panels/* file. Discarded"
end
end
|
.panel_exclusion ⇒ Object
25
26
27
|
# File 'lib/insight/panel.rb', line 25
def panel_exclusion
return @panel_exclusion ||= []
end
|
.panel_mappings ⇒ Object
90
91
92
|
# File 'lib/insight/panel.rb', line 90
def self.panel_mappings
{}
end
|
Instance Method Details
#after(env, status, headers, body) ⇒ Object
113
114
|
# File 'lib/insight/panel.rb', line 113
def after(env, status, , body)
end
|
#before(env) ⇒ Object
110
111
|
# File 'lib/insight/panel.rb', line 110
def before(env)
end
|
#call(env) ⇒ Object
74
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/insight/panel.rb', line 74
def call(env)
@env = env
logger.debug{ "Before call: #{self.name}" }
before(env)
status, , body = @app.call(env)
@request = Rack::Request.new(env)
logger.debug{ "After call: #{self.name}" }
after(env, status, , body)
env["insight.panels"] << self
return [status, , body]
end
|
#content_for_request(number) ⇒ Object
106
107
108
|
# File 'lib/insight/panel.rb', line 106
def content_for_request(number)
content rescue "" end
|
#has_content? ⇒ Boolean
94
95
96
|
# File 'lib/insight/panel.rb', line 94
def has_content?
true
end
|
#heading_for_request(number) ⇒ Object
102
103
104
|
# File 'lib/insight/panel.rb', line 102
def heading_for_request(number)
heading rescue "xxx" end
|
#name ⇒ Object
98
99
100
|
# File 'lib/insight/panel.rb', line 98
def name
"Unnamed panel: #{self.class.name}" end
|
#panel_app ⇒ Object
86
87
88
|
# File 'lib/insight/panel.rb', line 86
def panel_app
nil
end
|
#render(template) ⇒ Object
116
117
|
# File 'lib/insight/panel.rb', line 116
def render(template)
end
|