Class: Rack::DevInsight::SqlNotifications
- Inherits:
-
Object
- Object
- Rack::DevInsight::SqlNotifications
- Defined in:
- lib/rack/dev_insight/sql_notifications.rb
Constant Summary collapse
- DEFAULT_EVENT_NAMES =
%w[sql.active_record sql.rom sql.sequel].freeze
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.subscribe(event_name) ⇒ Object
14 15 16 |
# File 'lib/rack/dev_insight/sql_notifications.rb', line 14 def subscribe(event_name) ActiveSupport::Notifications.subscribe(event_name, &new) end |
.subscribe_events(event_names = DEFAULT_EVENT_NAMES) ⇒ Object
9 10 11 |
# File 'lib/rack/dev_insight/sql_notifications.rb', line 9 def subscribe_events(event_names = DEFAULT_EVENT_NAMES) event_names.each { |event_name| subscribe(event_name) } end |
Instance Method Details
#call(*args) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rack/dev_insight/sql_notifications.rb', line 23 def call(*args) _name, started, finished, _unique_id, data = args SqlRecorder.new.record_from_event( started: started, finished: finished, statement: data[:sql], binds: data[:type_casted_binds].try(:call) || data[:type_casted_binds], cached: data[:cached], ) end |
#to_proc ⇒ Object
19 20 21 |
# File 'lib/rack/dev_insight/sql_notifications.rb', line 19 def to_proc method(:call).to_proc end |