Class: UnionStationHooksRails::ActiveRecordSubscriber

Inherits:
ActiveSupport::LogSubscriber
  • Object
show all
Defined in:
lib/union_station_hooks_rails/active_record_subscriber.rb

Instance Method Summary collapse

Instance Method Details

#sql(event) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/union_station_hooks_rails/active_record_subscriber.rb', line 27

def sql(event)
  reporter = Thread.current[:union_station_hooks]
  return if !reporter

  UnionStationHooks.call_event_pre_hook(event)
  reporter.log_database_query(
    :begin_time => event.time,
    :end_time => UnionStationHooks.now,
    :query => event.payload[:sql]
  )
end