Created
June 6, 2015 21:50
-
-
Save mbj/20a0b7e739f32c2056fb to your computer and use it in GitHub Desktop.
Break ruby method dispatch
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 Foo | |
def bar | |
p :original | |
end | |
end | |
module SomeModule | |
def bar | |
p :some_module | |
end | |
end | |
object = Foo.new | |
p object.bar # :original as expected | |
Foo.prepend(SomeModule) | |
p object.bar # :some_module as expected | |
module Hooker | |
undef :meth | |
end | |
p object.meth # expect :original, but raises UndefinedMethod error |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment