Skip to content

Instantly share code, notes, and snippets.

@AJFaraday
Created May 26, 2017 15:33
Show Gist options
  • Save AJFaraday/6982015737d7ba0bbae624d1f6b31bdf to your computer and use it in GitHub Desktop.
Save AJFaraday/6982015737d7ba0bbae624d1f6b31bdf to your computer and use it in GitHub Desktop.
class Foo
def my_method
puts 'original'
end
end
module Bar
def my_method
puts 'overridden'
end
end
Foo.send(:include, Bar)
Foo.new.my_method
# original
@justinxreese
Copy link

justinxreese commented May 26, 2017

Would refinements work for your use case?

class Foo
  def my_method
    puts 'original'
  end
end
module Bar
  refine Foo do
    def my_method
      puts 'overridden'
    end
  end
end

using Bar

Foo.new.my_method
# overridden

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment