Last active
February 17, 2018 13:56
-
-
Save mudge/3d37a7ad906c6d74bd64d08f6fb6a56d to your computer and use it in GitHub Desktop.
A wrapper class for reporting on method calls useful for reverse engineering
This file contains hidden or 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
# snitch = Snitch.new('A string') | |
#=> #<Snitch:0x00007fe53a1964b0 @obj="A string"> | |
# snitch.empty? | |
# Calling empty? on A string with [] | |
#=> false | |
class Snitch | |
attr_reader :obj | |
def initialize(obj) | |
@obj = obj | |
end | |
def method_missing(name, *args, &blk) | |
puts "Calling #{name} on #{obj} with #{args.inspect}" | |
obj.send(name, *args, &blk) | |
end | |
def respond_to?(symbol) | |
obj.respond_to?(symbol) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment