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

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

Constant Summary

Constants inherited from Event::MethodEvent

Event::MethodEvent::MAX_ARRAY_ENUMERATION, Event::MethodEvent::MAX_HASH_ENUMERATION, Event::MethodEvent::MAX_STRING_LENGTH

Constants included from ValueInspector

ValueInspector::MAX_ARRAY_ELEMENTS, ValueInspector::MAX_DEPTH

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

add_schema, add_size, build_from_invocation, custom_display_string, default_display_string, display_string, encode_display_string, #ready?

Methods included from ValueInspector

#best_class_name, #detect_schema, #detect_size

Constructor Details

#initialize(payload) ⇒ SQLCall

Returns a new instance of SQLCall.



14
15
16
17
18
# File 'lib/appmap/handler/rails/sql_handler.rb', line 14

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.



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

def payload
  @payload
end

Instance Method Details

#to_hObject



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/appmap/handler/rails/sql_handler.rb', line 20

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