Created
December 22, 2023 00:21
-
-
Save lewispb/b8afd7f0912defb0ba2cafda3c738469 to your computer and use it in GitHub Desktop.
tracepoint
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TestObj | |
def method_missing(method_name, *args) | |
if method_name == :works? | |
true | |
else | |
super | |
end | |
end | |
def respond_to_missing?(method_name, include_private = false) | |
method_name == :works? || super | |
end | |
def something_else? | |
false | |
end | |
end | |
TracePoint.new(:a_call) { |tp| puts tp.inspect }.enable do | |
TestObj.new.works? | |
end | |
# Output: | |
#<TracePoint:b_call test.rb:19> | |
#<TracePoint:c_call `new' test.rb:20> | |
#<TracePoint:c_call `initialize' test.rb:20> | |
#<TracePoint:call `method_missing' test.rb:2> | |
#<TracePoint:c_call `==' test.rb:3> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment