Class: AppMap::Event::MethodEvent

Inherits:
MethodEventStruct show all
Defined in:
lib/appmap/event.rb

Constant Summary collapse

LIMIT =
100

Instance Attribute Summary

Attributes inherited from MethodEventStruct

#event, #id, #thread_id

Class Method Summary collapse

Class Method Details

.build_from_invocation(me, event_type) ⇒ Object



24
25
26
27
28
# File 'lib/appmap/event.rb', line 24

def build_from_invocation(me, event_type)
  me.id = AppMap::Event.next_id_counter
  me.event = event_type
  me.thread_id = Thread.current.object_id
end

.display_string(value) ⇒ Object

Gets a display string for a value. This is not meant to be a machine deserializable value.



31
32
33
34
35
36
37
# File 'lib/appmap/event.rb', line 31

def display_string(value)
  return nil unless value

  value_string = custom_display_string(value) || default_display_string(value)

  (value_string||'')[0...LIMIT].encode('utf-8', invalid: :replace, undef: :replace, replace: '_')
end

.object_properties(hash_like) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/appmap/event.rb', line 39

def object_properties(hash_like)
  hash = hash_like.to_h
  hash.keys.map do |key|
    {
      name: key,
      class: hash[key].class.name,
    }
  end
rescue
  nil
end