Last active
March 30, 2023 21:54
-
-
Save aantix/7cc1e4f95561627466d2d75d324cb0bd to your computer and use it in GitHub Desktop.
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
module Y | |
def hello(str) | |
puts "prepended before super" | |
super(str) | |
puts "prepended after super" | |
end | |
end | |
class X | |
def hello(str) | |
puts str | |
end | |
end | |
puts "-- non-prepended ---------" | |
x = X.new | |
x.hello('hi') | |
puts "-- prepended ------------" | |
X.prepend(Y) | |
x = X.new | |
x.hello('hi') | |
x = X.new | |
x.hello('hello') | |
puts "-- method removed -------" | |
Y.remove_method(:hello) | |
x.hello('hi') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment