lib/appmap/hook/method.rb in appmap-0.44.0 vs lib/appmap/hook/method.rb in appmap-0.45.0
- old
+ new
@@ -74,32 +74,30 @@
rescue
exception = $ERROR_INFO
raise
ensure
with_disabled_hook.call do
- after_hook.call(self, call_event, start_time, return_value, exception)
+ after_hook.call(self, call_event, start_time, return_value, exception) if call_event
end
end
end
end
hook_class.define_method_with_arity(hook_method.name, hook_method.arity, hook_method_def)
end
protected
def before_hook(receiver, defined_class, args)
- require 'appmap/event'
- call_event = AppMap::Event::MethodCall.build_from_invocation(defined_class, hook_method, receiver, args)
- AppMap.tracing.record_event call_event, package: hook_package, defined_class: defined_class, method: hook_method
+ call_event = hook_package.handler_class.handle_call(defined_class, hook_method, receiver, args)
+ AppMap.tracing.record_event(call_event, package: hook_package, defined_class: defined_class, method: hook_method) if call_event
[ call_event, TIME_NOW.call ]
end
def after_hook(_receiver, call_event, start_time, return_value, exception)
- require 'appmap/event'
elapsed = TIME_NOW.call - start_time
- return_event = \
- AppMap::Event::MethodReturn.build_from_invocation call_event.id, elapsed, return_value, exception
+ return_event = hook_package.handler_class.handle_return(call_event.id, elapsed, return_value, exception)
AppMap.tracing.record_event return_event
+ nil
end
def with_disabled_hook(&function)
# Don't record functions, such as to_s and inspect, that might be called
# by the fn. Otherwise there can be a stack overflow.