From what I can see, the following three ways are equivalent, when we
want to group methods into a namespace such that they can be called as,
i.e., NS.foo or NS.bar (or, equivalently, using a Module to get the
effect of a singleton class):
(1) Explicit self
module NS
def self.foo; ....; end
def self.bar; ....; end
end
(2) Implicit self
module NS
extend self;
def foo; ....; end
def bar; ....; end
end
(3) module_function
module NS
def foo; ....; end
def bar; ....; end
module_function :foo, :bar
end
So far, I have nearly always used variant (2), because it seemed to me
the easiest. Any opinions on this, i.e. whether maybe (1) or (3) would
be a better way to do it?
Ronald