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

Inherits:
Event::MethodCall show all
Defined in:
lib/appmap/rails/sql_handler.rb

Constant Summary

Constants inherited from Event::MethodEvent

Event::MethodEvent::LIMIT

Instance Attribute Summary collapse

Attributes inherited from Event::MethodCall

#defined_class, #lineno, #method_id, #parameters, #path, #receiver, #static

Attributes inherited from Event::MethodEventStruct

#event, #id, #thread_id

Instance Method Summary collapse

Methods inherited from Event::MethodCall

build_from_invocation

Methods inherited from Event::MethodEvent

build_from_invocation, display_string

Constructor Details

#initialize(payload) ⇒ SQLCall

Returns a new instance of SQLCall.



11
12
13
14
15
# File 'lib/appmap/rails/sql_handler.rb', line 11

def initialize(payload)
  super AppMap::Event.next_id_counter, :call, Thread.current.object_id

  self.payload = payload
end

Instance Attribute Details

#payloadObject

Returns the value of attribute payload.



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

def payload
  @payload
end

Instance Method Details

#to_hObject



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

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].each do |attribute|
        sql_query[attribute] = payload[attribute] if payload[attribute]
      end
    end
  end
end