In Python, you can set an alias for a module with 'as':
import mymodule as mm
But I can't seem to find an equivalent for ruby. I know that you can include
rather than require
a module, but this risks namespace collisions. Is there any equivalent to Python module aliases?
Modules in Ruby aren't really that special, so you can just assign them to another constant:
[4] (pry) main: 0> module TestModule
[4] (pry) main: 0* def self.foo
[4] (pry) main: 0* "test"
[4] (pry) main: 0* end
[4] (pry) main: 0* end
=> nil
[5] (pry) main: 0> tm = TestModule
=> TestModule
[6] (pry) main: 0> tm.foo
=> "test"