module A
def doit
puts 'A doit'
end
end
module B
def doit
puts 'B doit'
end
end
module C
def self.included(base)
base.prepend(InstanceMethods)
end
module InstanceMethods
def doit
puts 'C doit'
end
end
end
module D
def self.included(base)
base.class_eval do
def doit
puts 'D doit'
end
end
end
end
class Foo
include A
end
f = Foo.new
f.doit
# Not working
A.include(B)
f.doit
# Not working
A.include(C)
f.doit
# Working
A.include(D)
f.doit
bW9kdWxlIEEKICBkZWYgZG9pdAogICAgcHV0cyAnQSBkb2l0JwogIGVuZAplbmQKCm1vZHVsZSBCCiAgZGVmIGRvaXQKICAgIHB1dHMgJ0IgZG9pdCcKICBlbmQKZW5kCgptb2R1bGUgQwogIGRlZiBzZWxmLmluY2x1ZGVkKGJhc2UpCiAgICBiYXNlLnByZXBlbmQoSW5zdGFuY2VNZXRob2RzKQogIGVuZAoKICBtb2R1bGUgSW5zdGFuY2VNZXRob2RzCiAgICBkZWYgZG9pdAogICAgICBwdXRzICdDIGRvaXQnCiAgICBlbmQKICBlbmQKZW5kCgptb2R1bGUgRAogIGRlZiBzZWxmLmluY2x1ZGVkKGJhc2UpCiAgICBiYXNlLmNsYXNzX2V2YWwgZG8KICAgICAgZGVmIGRvaXQKICAgICAgICBwdXRzICdEIGRvaXQnCiAgICAgIGVuZAogICAgZW5kCiAgZW5kCmVuZAoKY2xhc3MgRm9vCiAgaW5jbHVkZSBBCmVuZAoKZiA9IEZvby5uZXcKCmYuZG9pdAoKIyBOb3Qgd29ya2luZwpBLmluY2x1ZGUoQikKZi5kb2l0CgojIE5vdCB3b3JraW5nCkEuaW5jbHVkZShDKQpmLmRvaXQKCiMgV29ya2luZwpBLmluY2x1ZGUoRCkKZi5kb2l0