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, &block) ⇒ Object
10
11
12
13
14
15
16
17
|
# File 'lib/rack/bug/panels/templates_panel.rb', line 10
def self.record(template, &block)
return block.call unless Rack::Bug.enabled?
template_trace.start(template)
result = block.call
template_trace.finished(template)
return result
end
|
.reset ⇒ Object
19
20
21
|
# File 'lib/rack/bug/panels/templates_panel.rb', line 19
def self.reset
Thread.current["rack.bug.template_trace"] = Trace.new
end
|
.template_trace ⇒ Object
23
24
25
|
# File 'lib/rack/bug/panels/templates_panel.rb', line 23
def self.template_trace
Thread.current["rack.bug.template_trace"] ||= Trace.new
end
|
Instance Method Details
#content ⇒ Object
35
36
37
38
39
|
# File 'lib/rack/bug/panels/templates_panel.rb', line 35
def content
result = render_template "panels/templates", :template_trace => self.class.template_trace
self.class.reset
return result
end
|
#heading ⇒ Object
31
32
33
|
# File 'lib/rack/bug/panels/templates_panel.rb', line 31
def heading
"Templates: %.2fms" % (self.class.template_trace.total_time * 1_000)
end
|
#name ⇒ Object
27
28
29
|
# File 'lib/rack/bug/panels/templates_panel.rb', line 27
def name
"templates"
end
|