Created
January 6, 2020 20:43
-
-
Save wagenet/74c9985e69f2f265da9b89f772397183 to your computer and use it in GitHub Desktop.
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 Target | |
def call | |
puts "Called" | |
end | |
end | |
module TargetPrepend | |
def call | |
puts "Prepend" | |
super | |
end | |
end | |
Target.prepend(TargetPrepend) | |
class Target | |
alias original_call call | |
def call | |
puts "Overwritten" | |
original_call | |
end | |
end | |
Target.new.call |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See https://blog.newrelic.com/engineering/ruby-agent-module-prepend-alias-method-chains/