I want to get in difference of implementation singleton pattern in ruby vs class and vs module.I'm talking about singleton with class methods only and no instances. As for me, it is logical to use
module Foo
def self.foo= other
@@foo=other
end
def self.foo
@@foo
end
end
but very often I see in others code class Foo;....;end
and I want to understand why?If there is no instances and no sub classes Module
is more convenient. Or may be I miss something?
The question is what is the diff between module and class in singleton pattern implementation?