Skip to content

Instantly share code, notes, and snippets.

@mudge
Last active February 17, 2018 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mudge/3d37a7ad906c6d74bd64d08f6fb6a56d to your computer and use it in GitHub Desktop.
Save mudge/3d37a7ad906c6d74bd64d08f6fb6a56d to your computer and use it in GitHub Desktop.
A wrapper class for reporting on method calls useful for reverse engineering
# 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