Class: AppMap::Event::MethodEvent
Constant Summary
collapse
- LIMIT =
100
Instance Attribute Summary
#event, #id, #thread_id
Class Method Summary
collapse
Class Method Details
.best_class_name(value) ⇒ Object
Heuristic for dynamically defined class whose name can be nil
52
53
54
55
56
57
58
|
# File 'lib/appmap/event.rb', line 52
def best_class_name(value)
value_cls = value.class
while value_cls.name.nil?
value_cls = value_cls.superclass
end
value_cls.name
end
|
.build_from_invocation(event_type, event:) ⇒ Object
24
25
26
27
28
|
# File 'lib/appmap/event.rb', line 24
def build_from_invocation(event_type, event:)
event.id = AppMap::Event.next_id_counter
event.event = event_type
event.thread_id = Thread.current.object_id
end
|
.custom_display_string(value) ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/appmap/event.rb', line 60
def custom_display_string(value)
case value
when File
"#{value.class}[path=#{value.path}]"
when Net::HTTP
"#{value.class}[#{value.address}:#{value.port}]"
when Net::HTTPGenericRequest
"#{value.class}[#{value.method} #{value.path}]"
end
rescue StandardError
nil
end
|
.default_display_string(value) ⇒ Object
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/appmap/event.rb', line 73
def default_display_string(value)
last_resort_string = lambda do
warn "AppMap encountered an error inspecting a #{value.class.name}: #{$!.message}"
'*Error inspecting variable*'
end
begin
value.to_s
rescue NoMethodError
begin
value.inspect
rescue StandardError
last_resort_string.call
end
rescue StandardError
last_resort_string.call
end
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
|