Class: AppMap::Rails::SQLHandler::SQLCall

Inherits:
Trace::MethodEvent show all
Defined in:
lib/appmap/rails/sql_handler.rb

Constant Summary

Constants inherited from Trace::MethodEvent

Trace::MethodEvent::COUNTER_LOCK, Trace::MethodEvent::LIMIT

Instance Attribute Summary collapse

Attributes inherited from Trace::MethodEventStruct

#defined_class, #event, #id, #lineno, #method_id, #path, #static, #thread_id

Instance Method Summary collapse

Methods inherited from Trace::MethodEvent

build_from_tracepoint, display_string, next_id, value_in_binding

Constructor Details

#initialize(path, lineno, payload) ⇒ SQLCall

Returns a new instance of SQLCall.



9
10
11
12
13
# File 'lib/appmap/rails/sql_handler.rb', line 9

def initialize(path, lineno, payload)
  super AppMap::Trace::MethodEvent.next_id, :call, SQLHandler, :call, path, lineno, false, Thread.current.object_id

  self.payload = payload
end

Instance Attribute Details

#payloadObject

Returns the value of attribute payload.



7
8
9
# File 'lib/appmap/rails/sql_handler.rb', line 7

def payload
  @payload
end

Instance Method Details

#to_hObject



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/appmap/rails/sql_handler.rb', line 15

def to_h
  super.tap do |h|
    h[:sql_query] = {
      sql: payload[:sql],
      database_type: payload[:database_type]
    }.tap do |sql_query|
      %i[server_version explain_sql].each do |attribute|
        sql_query[attribute] = payload[attribute] if payload[attribute]
      end
    end
  end
end