Class: Rack::Bug::TemplatesPanel::Trace

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/bug/panels/templates_panel/trace.rb

Instance Method Summary collapse

Constructor Details

#initializeTrace

Returns a new instance of Trace.



29
30
31
# File 'lib/rack/bug/panels/templates_panel/trace.rb', line 29

def initialize
  @current = root_rendering
end

Instance Method Details

#add(template_name, start_time, end_time, event) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/rack/bug/panels/templates_panel/trace.rb', line 14

def add(template_name, start_time, end_time, event)
  current = Rendering.new(template_name, start_time, end_time)
  root_rendering.children.each do |child|
    next unless event.parent_of?(child)
    root_rendering.delete(child)
    current.add(child)
  end
  root_rendering.add(current)
end

#finished(template_name) ⇒ Object



24
25
26
27
# File 'lib/rack/bug/panels/templates_panel/trace.rb', line 24

def finished(template_name)
  @current.end_time = Time.now
  @current = @current.parent
end

#root_renderingObject



37
38
39
# File 'lib/rack/bug/panels/templates_panel/trace.rb', line 37

def root_rendering
  @root_rendering ||= Rendering.new("root")
end

#start(template_name) ⇒ Object



7
8
9
10
11
12
# File 'lib/rack/bug/panels/templates_panel/trace.rb', line 7

def start(template_name)
  rendering = Rendering.new(template_name)
  rendering.start_time = Time.now
  @current.add(rendering)
  @current = rendering
end

#total_timeObject



33
34
35
# File 'lib/rack/bug/panels/templates_panel/trace.rb', line 33

def total_time
  root_rendering.duration
end