-
-
Save avdi/2720428 to your computer and use it in GitHub Desktop.
Possible for a module included somewhere to override a class's instance method?
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 Base | |
def call | |
'call' | |
end | |
end | |
Base.new.call # => "call" | |
module Override | |
def new(*) | |
super.extend(Pwned) | |
end | |
module Pwned | |
def call | |
"pwned! #{super.inspect}" | |
end | |
end | |
end | |
class Base | |
extend Override | |
end | |
Base.new.call # => "pwned! \"call\"" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment