Is there a way in ruby to load a module containing many classes and be able to access these classes without prefixing them with the module name? Consider foo.rb and bar.rb:
foo.rb:
require 'bar'
bar = BarModule::Bar.new()
bar.rb
module BarModule
class Bar
end
end
Basically I'd like the ability, from foo.rb, to refer to the class "Bar" without specifying its module every time I reference it. In java terms, I'm looking for something akin to:
import BarModule.*;
Anything like that exist?
Modules can be mixed in to one another. To use BarModule as a mixin, you want to include BarModule
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With