-
-
Save sorah/8265550 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 A | |
def say | |
puts "A" | |
end | |
end | |
module B | |
def self.test | |
ref = refine(A) { } | |
block = Proc.new do | |
def hey | |
puts "b" | |
end | |
def say | |
hey | |
end | |
end | |
ref.module_eval(&block) | |
end | |
test | |
end | |
class C | |
using B | |
def say | |
A.new.say | |
end | |
end | |
A.new.say # => A | |
C.new.say # undefined local variable or method `hey' for #<A:0x007f9e4c0a9cf8> (NameError) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment