Skip to content

Instantly share code, notes, and snippets.

@sorah sorah/refinements.rb forked from rosylilly/refinements.rb
Last active Jan 2, 2016

Embed
What would you like to do?
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
You can’t perform that action at this time.