Some interesting output from irb:
irb(main):001:0> Class.ancestors
=> [Class, Module, Object, Kernel, BasicObject]
irb(main):002:0> class Foo
irb(main):003:1> end
=> nil
irb(main):004:0> module Foo
irb(main):005:1> end
TypeError: Foo is not a module
from (irb):4
from D:/Ruby193/bin/irb:12:in '<main>'
irb(main):006:0> Foo.is_a? Module
=> true
According to definition of class, a class is a derived module which can be instantiated. But irb tells us, sometimes it is a module, and sometimes it is not…
The problem here is that you have created a
Class(Foo) and now are trying to redefine it as aModule. Regardless of the inheritance of classes and modules, you can’t change one into the other, or “cast” between them