Sha256: b200e19159e04a6d4015ebf221cbe5831fad10a918b603b725e115a2a76ddad8

Contents?: true

Size: 1.07 KB

Versions: 17

Compression:

Stored size: 1.07 KB

Contents

module Rack::Insight
  class TemplatesPanel
    class Stats
      require 'rack/insight/panels/templates_panel/rendering'

      include Rack::Insight::Logging

      attr_reader :root, :current

      def initialize(*args)
        @root = Rack::Insight::TemplatesPanel::Rendering.new(*args)
        @current = @root
      end

      # Track when each template starts being rendered
      def begin_record!(rendering)
        @current.add!(rendering) # Add the rendering as a child of the current and make rendering the new current
        @current = rendering
      end

      # Track when each template finishes being rendered, move current back up the rendering chain
      def finish_record!(timing)
        # This is the one being completed now, and for which we now know the timing duration
        @current.finish!(timing)
        # Prepare for the next template to finish
        @current = @current.parent
      end

      def finish!
        @root.finish!(root._calculate_child_time)
        @current = nil
      end

      def to_s
        "#{self.root.to_s}"
      end

    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
rack-insight-0.6.4 lib/rack/insight/panels/templates_panel/stats.rb
rack-insight-0.6.3 lib/rack/insight/panels/templates_panel/stats.rb
rack-insight-0.6.2 lib/rack/insight/panels/templates_panel/stats.rb
rack-insight-0.5.30 lib/rack/insight/panels/templates_panel/stats.rb
rack-insight-0.5.29 lib/rack/insight/panels/templates_panel/stats.rb
rack-insight-0.5.28 lib/rack/insight/panels/templates_panel/stats.rb
rack-insight-0.5.27 lib/rack/insight/panels/templates_panel/stats.rb
rack-insight-0.5.26 lib/rack/insight/panels/templates_panel/stats.rb
rack-insight-0.5.25 lib/rack/insight/panels/templates_panel/stats.rb
rack-insight-0.5.24 lib/rack/insight/panels/templates_panel/stats.rb
rack-insight-0.5.23 lib/rack/insight/panels/templates_panel/stats.rb
rack-insight-0.5.22 lib/rack/insight/panels/templates_panel/stats.rb
rack-insight-0.5.21 lib/rack/insight/panels/templates_panel/stats.rb
rack-insight-0.5.20 lib/rack/insight/panels/templates_panel/stats.rb
rack-insight-0.5.19 lib/rack/insight/panels/templates_panel/stats.rb
rack-insight-0.5.18 lib/rack/insight/panels/templates_panel/stats.rb
rack-insight-0.5.17 lib/rack/insight/panels/templates_panel/stats.rb