Skip to content

Instantly share code, notes, and snippets.

@aantix
Last active March 30, 2023 21:54
Show Gist options
  • Save aantix/7cc1e4f95561627466d2d75d324cb0bd to your computer and use it in GitHub Desktop.
Save aantix/7cc1e4f95561627466d2d75d324cb0bd to your computer and use it in GitHub Desktop.
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