A simple Module Example
As with classes, you may use the double-colon scope resolution operator to access constants (including classes and other modules) declared inside modules.
While each class can only descend from one superclass, it can mix in numerous modules.
Modules can be thought of as discrete code units which can simplify the creation of reusable code libraries.
The process of including a module is also called ‘mixing in’ – which explains why included modules are often called ‘mixins’.
An object can access the instance methods of a module by including that module using the include method.
You can think of a module as a sort of named ‘wrapper’ around a set of methods, constants and classes.
the Class class is itself a descendent of the Module class. It inherits the behaviour of Module and adds on some important new behaviour – notably the ability to create objects.
Find out what a module really is. It turns out that, as with most other things in Ruby, a module is an object. Each named module is, in fact, an instance of the Module class
If you want a function to be available both as an instance and a module method, you can use the module_function method with a symbol matching the name of an instance method