Let's say I have a singleton class like this:
class Settings
include Singleton
def timeout
# lazy-load timeout from config file, or whatever
end
end
Now if I want to know what timeout to use I need to write something like:
Settings.instance.timeout
but I'd rather shorten that to
Settings.timeout
One obvious way to make this work would be to modify the implementation of Settings to:
class Settings
include Singleton
def self.timeout
instance.timeout
end
def timeout
# lazy-load timeout from config file, or whatever
end
end
That works, but it would be rather tedious to manually write out a class method for each instance method. This is ruby, there must be a clever-clever dynamic way to do this.