Class: RuntimeProfiler::Callback::ActiveRecord

Inherits:
Object
  • Object
show all
Defined in:
lib/runtime_profiler/callbacks/active_record.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeActiveRecord

Returns a new instance of ActiveRecord.



8
9
10
# File 'lib/runtime_profiler/callbacks/active_record.rb', line 8

def initialize
  @data = {}
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



6
7
8
# File 'lib/runtime_profiler/callbacks/active_record.rb', line 6

def data
  @data
end

Instance Method Details

#call(*args) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/runtime_profiler/callbacks/active_record.rb', line 12

def call(*args)
  event = RuntimeProfiler::SqlEvent.new(args: args, trace: caller)

  return unless event.recordable?
  return if event.trace.empty?

  @data.key?(event.key) ? update(event) : add(event)
end