I am new to Ruby but have been looking through some source code. I came across the kind of structures shown below in some source code (names of modules, classes not the real ones)
module ModuleOne
class MyClass
module CommonModule
# code ....
end # module CommonModule
end # class MyClass
end # module ModuleOne
or this example
module ModuleOne
class MyClass
class MyClassTwo
#code ............
end #class MyClassTwo
end #class MyClass
end #module ModuleOne
From my reading so far I know about wrapping classes in modules, but I haven't heard of the kinds of wrapping (modules inside modules or classes in classes for example) shown above. Can I ask, 1. Is this good practice and commonly done ? 2. What is the advantage of structuring code in this way ?
Thanks for any comments or pointers
Dave