-
-
Save udzura/5028199 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 Moge | |
def moge1; p "Moge#moge1"; end | |
def moge2; p "Moge#moge2"; end | |
end | |
module OverwrapMoge | |
def moge1 | |
super | |
# It's a fancy ruby wolrd | |
self.class.instance_method(:moge2).bind(self).call | |
end | |
def moge2 | |
p "from OverwrapMoge#moge2" | |
super | |
end | |
end | |
class Moge | |
prepend OverwrapMoge | |
end | |
=begin | |
class Hoge < Moge | |
def moge1_with_hoge | |
moge1_without_hoge | |
moge2_without_hoge | |
end | |
alias_method_chain :moge1, :hoge | |
def moge2_with_hoge | |
moge2_without_hoge | |
end | |
alias_method_chain :moge2, :hoge | |
end | |
=end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this c9958152e2eceff65c4adaa95ae001d929bf42a4 does not work