I have a file SomethingClass.rb
which looks as follows:
class SomethingClass
def initialize
puts "Hello World"
end
end
I would like to require
the file SomethingClass.rb
, and make SomethingClass
part of the module SomethingModule
without changing the file.
Also, I would like to avoid making SomethingClass
part of the namespace outside of that module at all. In other words, I want to require
the file and the rest of my application should not change apart from the fact that SomethingModule
will be defined.
This does not work (I assume because require
is executed in Kernel
scope):
module SomethingModule
require './SomethingClass.rb'
end
Is this possible in Ruby?