title: How to add convenience class methods to a Singleton class in ruby
body: <p>Let's say I have a singleton class like this:</p>
  
  <pre><code>class Settings
    include Singleton
  
    def timeout
      # lazy-load timeout from config file, or whatever
    end
  end
  </code></pre>
  
  <p>Now if I want to know what timeout to use I need to write something like:</p>
  
  <pre><code>Settings.instance.timeout
  </code></pre>
  
  <p>but I'd rather shorten that to </p>
  
  <pre><code>Settings.timeout
  </code></pre>
  
  <p>One obvious way to make this work would be to modify the implementation of Settings to:</p>
  
  <pre><code>class Settings
    include Singleton
  
    def self.timeout
      instance.timeout
    end
  
    def timeout
      # lazy-load timeout from config file, or whatever
    end
  end
  </code></pre>
  
  <p>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.</p>