title: How can I mix in Singleton to create a class that accepts initialization parameters?
body: <p>I've seen how to define a class as being a singleton (<a href="https://stackoverflow.com/questions/4677/how-do-i-create-a-class-using-the-singleton-design-pattern-in-ruby">how to create a singleton in Ruby</a>):</p>
  <pre><code>require 'singleton'
   
  class Example
    include Singleton
  end
  </code></pre>
  <p>But what if I want to pass some parameters to #new when initializing that single instance? Example should always have certain properties initialized. For example, say I had a class whose sole purpose is to log to a file but it requires a name of a file to log to before it can work.</p>
  <pre><code>class MyLogger
    def initialize(file_name)
      @file_name = file_name
    end
  end
  </code></pre>
  <p>How can I make MyLogger a singleton but make sure it gets a file_name?</p>