My understanding is that, when a module is included into a class, a copy of the module is made and put between the including class and its superclass. Let me quote from Ruby Under a Microscope by Pat Shaughnessy. Suppose that you have the following:
module Professor
end
class Mathematician < Person
include Professor
end
When we run the above code, Ruby creates a copy of the
RClass
structure for theProfessor
module and uses it as the new superclass forMathematician
. Ruby's C source code refers to this copy of the module as an included class. The superclass of the new copy ofProfessor
is set to the original superclass ofMathematician
, which preserves the superclass, or ancestor chain.
Is it possible to get a reference to the included class? For example, I want to get a reference to the Kernel
module included in the Object
class.