Skip to content

Instantly share code, notes, and snippets.

@sorah
Forked from rosylilly/refinements.rb
Last active January 2, 2016 06:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sorah/8265550 to your computer and use it in GitHub Desktop.
Save sorah/8265550 to your computer and use it in GitHub Desktop.
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