Sha256: 2ddc4321478fa77bc01c59e1b9dfe297c9fbaca4e9dda9a827a3679703719048

Contents?: true

Size: 749 Bytes

Versions: 20

Compression:

Stored size: 749 Bytes

Contents

module Rack::Insight
  class ActiveRecordPanel < Panel

    def request_start(env, start)
      @records = Hash.new{ 0 }
    end

    def after_detect(method_call, timing, results, args)
      @records[method_call.object.base_class.name] += 1
    end

    def request_finish(env, status, headers, body, timing)
      store(env, @records)
    end

    def heading_for_request(number)
      record = retrieve(number).first
      total = record.inject(0) do |memo, (key, value)|
        memo + value
      end
      "#{total} AR Objects"
    end

    def content_for_request(number)
      records = retrieve(number).first.to_a.sort_by { |key, value| value }.reverse
      render_template "panels/active_record", :records => records
    end

  end

end

Version data entries

20 entries across 20 versions & 1 rubygems

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