RubyTapas Episode 13: Singleton Objects

Sometimes one instance is all you need.

Like what you see? This is just a taste of RubyTapas! Sign up today to get two videos a week, along with full source code and transcripts. Or click here to learn more.
This entry was posted in Ruby, RubyTapas Samples, Screencasts, Videos. Bookmark the permalink.
  • Pingback: This Week in Ruby: JRuby 1.7.0, Passenger 4.0b1, Ruby 2.0 Feature Freeze

  • Alex Conner

    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.

    • Avdi Grimm

      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.