Skip to content

Instantly share code, notes, and snippets.

@cbrunsdon
Created June 18, 2013 23:40
Show Gist options
  • Save cbrunsdon/5810498 to your computer and use it in GitHub Desktop.
Save cbrunsdon/5810498 to your computer and use it in GitHub Desktop.
lols caller()
class Foo
def hello
puts "Original Method"
puts caller(1)
end
end
class HijackStuff
def hijack
Foo.class_eval do
define_method(:hello) do
puts "Got My New Method"
puts caller(1)
end
end
end
end
def do_stuff
HijackStuff.new.hijack
Foo.new.hello
end
do_stuff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment