Sha256: 4e4dfb52d2cbf3e7c8d996b4b976196d7d692d9924826659845515836f652865

Contents?: true

Size: 385 Bytes

Versions: 1

Compression:

Stored size: 385 Bytes

Contents

# Derived from http://stackoverflow.com/a/13423584/153896
module ActiveRecord
  class QueryCounter
    attr_reader :query_count

    def initialize
      @query_count = 0
    end

    def to_proc
      lambda(&method(:callback))
    end

    def callback(name, start, finish, message_id, values)
      @query_count += 1 unless %w(CACHE SCHEMA).include?(values[:name])
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
read_activity-0.1.0 spec/support/query_counter.rb