Skip to content

Instantly share code, notes, and snippets.

@udzura
Forked from sonots/method_chain
Last active December 14, 2015 04:29
Show Gist options
  • Save udzura/5028199 to your computer and use it in GitHub Desktop.
Save udzura/5028199 to your computer and use it in GitHub Desktop.
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
@udzura
Copy link
Author

udzura commented Feb 25, 2013

this c9958152e2eceff65c4adaa95ae001d929bf42a4 does not work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment