Skip to content

Instantly share code, notes, and snippets.

@saraid
Created February 8, 2019 23:37
Show Gist options
  • Save saraid/5e5957b23c8d3b6f8626f3271d6d2a33 to your computer and use it in GitHub Desktop.
Save saraid/5e5957b23c8d3b6f8626f3271d6d2a33 to your computer and use it in GitHub Desktop.
how to combine refinements
module Refinements
module DoFoo
refine Object do
def foo; :foo; end
end
end
module DoBar
refine Object do
def bar; :bar; end
end
end
module FooAndBar
include DoFoo
include DoBar
end
end
class A
using Refinements::FooAndBar
def self.test
[1.foo, 1.bar]
end
end
begin
A.test
puts "Success."
rescue NoMethodError
puts "Nope."
raise
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment