Skip to content

Instantly share code, notes, and snippets.

@LTe
Forked from jasiek/gist:1627013
Created January 17, 2012 16:09
Show Gist options
  • Save LTe/1627247 to your computer and use it in GitHub Desktop.
Save LTe/1627247 to your computer and use it in GitHub Desktop.
module M
def self.included(base)
self.instance_methods.each do |method|
alias_method "#{self.to_s}_#{method}".to_sym, method.to_sym
end
end
def hello
1
end
end
module N
include M
def hello
2 + super
end
end
class C
include N
end
puts C.new.hello # 3
class C
def hello
7 + M.instance_method(:hello).bind(self).call
end
end
puts C.new.hello # 8
class C
def hello
send("M_hello")
end
end
puts C.new.hello # 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment