Module: SqlSpy

Defined in:
lib/sql_spy.rb

Defined Under Namespace

Classes: Query, Tracker

Class Method Summary collapse

Class Method Details

.trackObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/sql_spy.rb', line 39

def self.track

  tracker = Tracker.new

  subscriber = ActiveSupport::Notifications.subscribe("sql.active_record", tracker)

  begin
    yield
  ensure
    ActiveSupport::Notifications.unsubscribe(subscriber)
  end

  tracker.queries
end