I have a ruby module which includes many other modules. Here’s a quick example:
module Foo
module Bar
end
module Baz
end
end
except, I have like 6-7 modules inside Foo module. Is there a way I can put Bar/Baz in separate file but still get the same behavior? Right now all my code is inside 1 file, very unorganized.
You can define them like this, each in a separate file:
NB. You will need to define the
Foomodule before being able to define modules such asFoo::Barwith this notation.Or you could just put them in differently named files in the format they’re currently in and it should still work: