Created
June 18, 2013 23:40
-
-
Save cbrunsdon/5810498 to your computer and use it in GitHub Desktop.
lols caller()
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
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