@@ -69,28 +69,24 @@ def activate
6969 after_hook = self . method ( :after_hook )
7070 with_disabled_hook = self . method ( :with_disabled_hook )
7171
72- hook_method_def = Proc . new do |*args , &block |
73- is_array_containing_empty_hash = -> ( obj ) {
74- obj . is_a? ( Array ) && obj . length == 1 && obj [ 0 ] . is_a? ( Hash ) && obj [ 0 ] . size == 0
75- }
76-
77- call_instance_method = -> {
78- # https://github.com/applandinc/appmap-ruby/issues/153
79- if NEW_RUBY && is_array_containing_empty_hash . ( args ) && hook_method . arity == 1
80- if NEW_RUBY
81- hook_method . bind_call ( self , { } , &block )
82- else
83- hook_method . bind ( self ) . call ( { } , &block )
84- end
72+ is_array_containing_empty_hash = -> ( obj ) {
73+ obj . is_a? ( Array ) && obj . length == 1 && obj [ 0 ] . is_a? ( Hash ) && obj [ 0 ] . size == 0
74+ }
75+
76+ call_instance_method = lambda do |receiver , args , &block |
77+ # https://github.com/applandinc/appmap-ruby/issues/153
78+ if NEW_RUBY && is_array_containing_empty_hash . ( args ) && hook_method . arity == 1
79+ hook_method . bind_call ( receiver , { } , &block )
80+ else
81+ if NEW_RUBY
82+ hook_method . bind_call ( receiver , *args , &block )
8583 else
86- if NEW_RUBY
87- hook_method . bind_call ( self , *args , &block )
88- else
89- hook_method . bind ( self ) . call ( *args , &block )
90- end
84+ hook_method . bind ( receiver ) . call ( *args , &block )
9185 end
92- }
86+ end
87+ end
9388
89+ hook_method_def = Proc . new do |*args , &block |
9490 # We may not have gotten the class for the method during
9591 # initialization (e.g. for a singleton method on an embedded
9692 # struct), so make sure we have it now.
@@ -112,7 +108,7 @@ def activate
112108 return_value = nil
113109 exception = nil
114110 begin
115- return_value = call_instance_method . call
111+ return_value = call_instance_method . call ( self , args , & block )
116112 rescue
117113 exception = $ERROR_INFO
118114 raise
0 commit comments