Module is one of the most important tool in the Ruby toolbox. They are generally used to namespace ruby classes.
The class Hello will be wrapped in the Test namespace which means that if we want to create an instance of the Hello class , we can prefix it with the namespace and two colons.
a = Test::Hello.new
We generally provide namespace to classes to avoid collisions between them. If i write a library with a certain class and you use my library in your class which already has a class with the same name as that of mine , then the definitions of both the classes will merge into one class , usually causing unexpected behaviour.
# In testing/assetbase.rb
class AssetBase < ActiveRecord::Base
# In testing/textbase.rb
class TextBase < ActiveRecord::Base
# Used in a controller:
asset = Testing::AssetBase.new
text = Testing::TextBase.new
It will be stored in a subfolder of models with the name of the namespace, so here app/models/testing/*.rb