Hi list,
Is there a built-in inverse operation of Module#include? Currently I have:
class A
end
module B
def foo
:b
end
end
module C
def foo
:c
end
end
a = A.new
class A
include B
end
p a.foo # => :b
class A
include C
end
p a.foo # => :c
class A
include B
end
p a.foo # => :c
So if module B has already been mixed in, it cannot be re-included again
thus the foo method is not redefined to B#foo in the last include
operation. Thus occurs to me when I use Inversion of Control (or
dependency injection) to switch between various implementations of a
certain interface. I was thinking that if I can somehow "exclude" the
module and include it again then the problem would be solved, and hence
the question.
Or better yet, is there another way to achieve this kind of
implementation switching?
Regards,
Su