Ruby 2.0 How do I uninclude a module out from a module after including it?

The genuine answer is that in Ruby, be it 1.x or 2.x, there is no way to uninclude a module once included. But I know that someone, somewhere has written Ruby extension that allows unincluding modules.

EDIT: OK, actually, OP is the duplicate of What is the opposite of Ruby's include?, so according to its answer by @eliah and banister the libraries in question are https://github.com/yrashk/rbmodexcl and https://github.com/banister/mixology19


If you really need this kind of functionality, you could probably do it by using refinements.

class Foo
end

module X
  def x
    puts 'x'
  end
end

module Y
end

module R
  refine Foo do
    include X
    include Y
  end
end

# In a separate file or class
using R
# Foo now includes X and Y
Foo.new.x

# In a different file or class
# Foo no longer includes X and Y
Foo.new.x # NoMethodError