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::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

best_class_name, build_from_invocation, custom_display_string, default_display_string, display_string, object_properties

Constructor Details

#initialize(payload) ⇒ SQLCall

Returns a new instance of SQLCall.



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

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.



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

def payload
  @payload
end

Instance Method Details

#to_hObject



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

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