Sometimes one instance is all you need.

httpv://youtube.com/watch?v=J6fgEFBeepY

[boilerplate bypath=”rubytapas-sample”]

Published by Avdi Grimm

3 Comments

  1. Why not just use the Singleton Module in stdlib to build your Singletons? This would obviate the need for such strange construction syntax and further clarify (and provide a route to documentation) your intent.

    http://www.ruby-doc.org/stdlib-1.9.3/libdoc/singleton/rdoc/Singleton.html

    Reply
    • The Singleton module is about finding a way to force a class to only permit a single instance. The whole point of this episode is to say, why start with a class and then try to lock it down to once instance? Why not just start with an instance?

      The Singleton Pattern (and Ruby library) is kind of orthogonal, I talk about it more in another episode.

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *