class Mongoid::QueryCounter
Attributes
events[R]
Public Class Methods
new()
click to toggle source
# File lib/mongoid/support/query_counter.rb, line 6 def initialize @events = [] end
Public Instance Methods
inspect()
click to toggle source
# File lib/mongoid/support/query_counter.rb, line 19 def inspect @events.map { |e| e.payload[:ops].map(&:log_inspect) }.join("\n") end
instrument() { || ... }
click to toggle source
# File lib/mongoid/support/query_counter.rb, line 10 def instrument subscriber = ActiveSupport::Notifications.subscribe('query.moped') do |*args| @events << ActiveSupport::Notifications::Event.new(*args) end yield ensure ActiveSupport::Notifications.unsubscribe(subscriber) end