Class: Rack::Bug::TemplatesPanel
- Inherits:
-
Panel
- Object
- Panel
- Rack::Bug::TemplatesPanel
show all
- Defined in:
- lib/rack/bug/panels/templates_panel.rb,
lib/rack/bug/panels/templates_panel/trace.rb,
lib/rack/bug/panels/templates_panel/rendering.rb
Defined Under Namespace
Classes: Rendering, Trace
Instance Attribute Summary
Attributes inherited from Panel
#request
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Panel
#after, #before, #call, #has_content?, #initialize, #panel_app, #render
Methods included from Render
#compile, #compile!, #compiled_source, #method_name, #method_name_without_locals, #render_template, #signed_params
Class Method Details
.record(template) ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/rack/bug/panels/templates_panel.rb', line 10
def self.record(template)
return yield unless Rack::Bug.enabled?
template_trace.start(template)
begin
result = yield
ensure
template_trace.finished(template)
end
return result
end
|
.reset ⇒ Object
22
23
24
|
# File 'lib/rack/bug/panels/templates_panel.rb', line 22
def self.reset
Thread.current["rack.bug.template_trace"] = Trace.new
end
|
.template_trace ⇒ Object
26
27
28
|
# File 'lib/rack/bug/panels/templates_panel.rb', line 26
def self.template_trace
Thread.current["rack.bug.template_trace"] ||= Trace.new
end
|
Instance Method Details
#content ⇒ Object
38
39
40
41
42
|
# File 'lib/rack/bug/panels/templates_panel.rb', line 38
def content
result = render_template "panels/templates", :template_trace => self.class.template_trace
self.class.reset
return result
end
|
#heading ⇒ Object
34
35
36
|
# File 'lib/rack/bug/panels/templates_panel.rb', line 34
def heading
"Templates: %.2fms" % (self.class.template_trace.total_time * 1_000)
end
|
#name ⇒ Object
30
31
32
|
# File 'lib/rack/bug/panels/templates_panel.rb', line 30
def name
"templates"
end
|