Skip to content

Instantly share code, notes, and snippets.

@hanachin
Forked from ujihisa/break-sin_refinements.rb
Last active August 1, 2018 15:57
Show Gist options
  • Save hanachin/1c2a564095bd67952f9dd49ebfaa1a86 to your computer and use it in GitHub Desktop.
Save hanachin/1c2a564095bd67952f9dd49ebfaa1a86 to your computer and use it in GitHub Desktop.
require 'with_refinements'
module Ext
refine Integer do
def asdjflk
"ujihisa #{self}"
end
end
end
class C
using WithRefinements
def x
123
end
def f
x = 234
p x() #=> 123
with_refinements(Ext) do
p x().asdjflk #=> "ujihisa 123"
p binding.local_variable_get(:x).asdjflk #=> "ujihisa 234"
end
end
end
puts '----------------------'
C.new.f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment