Class: AppMap::Hook::Method
- Defined in:
- lib/appmap/hook/method.rb,
lib/appmap/hook/method/ruby2.rb,
lib/appmap/hook/method/ruby3.rb
Overview
Delegation methods for Ruby 3.
Direct Known Subclasses
AppMap::Handler::Function, AppMap::Handler::NetHTTP, AppMap::Handler::Rails::RequestHandler::HookMethod, AppMap::Handler::Rails::Template::RenderHandler
Instance Attribute Summary collapse
-
#arity ⇒ Object
readonly
Returns the value of attribute arity.
-
#hook_class ⇒ Object
readonly
Returns the value of attribute hook_class.
-
#hook_method ⇒ Object
readonly
Returns the value of attribute hook_method.
-
#hook_package ⇒ Object
readonly
Returns the value of attribute hook_package.
-
#parameters ⇒ Object
readonly
Returns the value of attribute parameters.
Instance Method Summary collapse
- #activate ⇒ Object
- #call(receiver, *args, **kwargs, &block) ⇒ Object
-
#initialize(hook_package, hook_class, hook_method) ⇒ Method
constructor
A new instance of Method.
Constructor Details
#initialize(hook_package, hook_class, hook_method) ⇒ Method
29 30 31 32 33 34 35 |
# File 'lib/appmap/hook/method.rb', line 29 def initialize(hook_package, hook_class, hook_method) @hook_package = hook_package @hook_class = hook_class @hook_method = hook_method @parameters = hook_method.parameters @arity = hook_method.arity end |
Instance Attribute Details
#arity ⇒ Object (readonly)
Returns the value of attribute arity.
24 25 26 |
# File 'lib/appmap/hook/method.rb', line 24 def arity @arity end |
#hook_class ⇒ Object (readonly)
Returns the value of attribute hook_class.
24 25 26 |
# File 'lib/appmap/hook/method.rb', line 24 def hook_class @hook_class end |
#hook_method ⇒ Object (readonly)
Returns the value of attribute hook_method.
24 25 26 |
# File 'lib/appmap/hook/method.rb', line 24 def hook_method @hook_method end |
#hook_package ⇒ Object (readonly)
Returns the value of attribute hook_package.
24 25 26 |
# File 'lib/appmap/hook/method.rb', line 24 def hook_package @hook_package end |
#parameters ⇒ Object (readonly)
Returns the value of attribute parameters.
24 25 26 |
# File 'lib/appmap/hook/method.rb', line 24 def parameters @parameters end |
Instance Method Details
#activate ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/appmap/hook/method.rb', line 37 def activate if Hook::LOG msg = if method_display_name "#{method_display_name}" else "#{hook_method.name} (class resolution deferred)" end warn "AppMap: Hooking #{msg} at line #{(hook_method.source_location || []).join(':')}" end hook_method_parameters = hook_method.parameters.dup.freeze SIGNATURES[[ hook_class, hook_method.name ]] = hook_method_parameters # irb(main):001:0> Kernel.public_instance_method(:system) # (irb):1:in `public_instance_method': method `system' for module `Kernel' is private (NameError) if hook_class == Kernel hook_class.define_method_with_arity(hook_method.name, hook_method.arity, hook_method_def) else hook_class.ancestors.find { |cls| cls.method_defined?(hook_method.name, false) }.tap do |cls| if cls cls.define_method_with_arity(hook_method.name, hook_method.arity, hook_method_def) else warn "#{hook_method.name} not found on #{hook_class}" end end end end |
#call(receiver, *args, **kwargs, &block) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/appmap/hook/method/ruby3.rb', line 7 def call(receiver, *args, **kwargs, &block) return do_call(receiver, *args, **kwargs, &block) unless trace? call_event = with_disabled_hook { before_hook receiver, *args, **kwargs } trace_call call_event, receiver, *args, **kwargs, &block end |