Reputation: 2091
Whenever you define a new module you call the method module
:
module A
...
end
I've looked for it in https://ruby-doc.org/core-2.7.2/ but I didn't find it. Where is it?
Upvotes: 0
Views: 173
Reputation: 84453
While module
is certainly a defined Ruby keyword, the underlying implementation is more complex. Pragmatically, a Module is a class-like Object that serves as the parent class of Class. It provides namespacing, and offers some additional features for mixin and module/class composition.
AFAICT, the syntax for creating a Module definition (rather than instantiating it) is handled by the RACC grammar, so if you’re looking for implementation details you may want to explore RACC, Ripper, and other interpreter elements to determine how the keyword actually implements the module definition.
Upvotes: 2
Reputation: 55908
The module
keyword is exactly that: a keyword, not a method. Since this is part of Ruby's language syntax it is not documented along with defined classes and their methods, but in its syntax documentation at
https://ruby-doc.org/core-2.7.2/doc/syntax/modules_and_classes_rdoc.html#label-Modules
Upvotes: 3