Class: AppMap::Event::MethodCall
- Inherits:
-
MethodEvent
- Object
- Struct
- MethodEventStruct
- MethodEvent
- AppMap::Event::MethodCall
- Defined in:
- lib/appmap/event.rb
Direct Known Subclasses
Defined Under Namespace
Classes: MethodMetadata
Constant Summary collapse
- @@method_metadata =
{}
Constants inherited from MethodEvent
AppMap::Event::MethodEvent::LIMIT
Instance Attribute Summary collapse
-
#defined_class ⇒ Object
Returns the value of attribute defined_class.
-
#lineno ⇒ Object
Returns the value of attribute lineno.
-
#method_id ⇒ Object
Returns the value of attribute method_id.
-
#parameters ⇒ Object
Returns the value of attribute parameters.
-
#path ⇒ Object
Returns the value of attribute path.
-
#receiver ⇒ Object
Returns the value of attribute receiver.
-
#static ⇒ Object
(also: #static?)
Returns the value of attribute static.
Attributes inherited from MethodEventStruct
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from MethodEvent
best_class_name, custom_display_string, default_display_string, display_string, encode_display_string, object_properties, #ready?
Instance Attribute Details
#defined_class ⇒ Object
Returns the value of attribute defined_class.
141 142 143 |
# File 'lib/appmap/event.rb', line 141 def defined_class @defined_class end |
#lineno ⇒ Object
Returns the value of attribute lineno.
141 142 143 |
# File 'lib/appmap/event.rb', line 141 def lineno @lineno end |
#method_id ⇒ Object
Returns the value of attribute method_id.
141 142 143 |
# File 'lib/appmap/event.rb', line 141 def method_id @method_id end |
#parameters ⇒ Object
Returns the value of attribute parameters.
141 142 143 |
# File 'lib/appmap/event.rb', line 141 def parameters @parameters end |
#path ⇒ Object
Returns the value of attribute path.
141 142 143 |
# File 'lib/appmap/event.rb', line 141 def path @path end |
#receiver ⇒ Object
Returns the value of attribute receiver.
141 142 143 |
# File 'lib/appmap/event.rb', line 141 def receiver @receiver end |
#static ⇒ Object Also known as: static?
Returns the value of attribute static.
141 142 143 |
# File 'lib/appmap/event.rb', line 141 def static @static end |
Class Method Details
.build_from_invocation(defined_class, method, receiver, arguments, event: MethodCall.new) ⇒ Object
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
# File 'lib/appmap/event.rb', line 171 def build_from_invocation(defined_class, method, receiver, arguments, event: MethodCall.new) event ||= MethodCall.new defined_class ||= 'Class' event.tap do = (defined_class, method, receiver) event.defined_class = .defined_class event.method_id = .method_id event.path = .path event.lineno = .lineno event.static = .static # Check if the method has key parameters. If there are any they'll always be last. # If yes, then extract it from arguments. has_key = [[:dummy], *method.parameters].last.first.to_s.start_with?('key') && arguments[-1].is_a?(Hash) kwargs = has_key && arguments[-1].dup || {} event.parameters = method.parameters.map.with_index do |method_param, idx| param_type, param_name = method_param param_name ||= 'arg' value = case param_type when :keyrest kwargs when /^key/ kwargs.delete param_name when :rest arguments[idx..(has_key ? -2 : -1)] else arguments[idx] end { name: param_name, class: best_class_name(value), object_id: value.__id__, value: display_string(value), kind: param_type } end event.receiver = { class: best_class_name(receiver), object_id: receiver.__id__, value: display_string(receiver) } MethodEvent.build_from_invocation(:call, event: event) end end |
Instance Method Details
#to_h ⇒ Object
221 222 223 224 225 226 227 228 229 230 231 232 |
# File 'lib/appmap/event.rb', line 221 def to_h super.tap do |h| h[:defined_class] = defined_class h[:method_id] = method_id h[:path] = path h[:lineno] = lineno h[:static] = static h[:parameters] = parameters h[:receiver] = receiver h.delete_if { |_, v| v.nil? } end end |