Sometimes one instance is all you need.
httpv://youtube.com/watch?v=J6fgEFBeepY
[boilerplate bypath=”rubytapas-sample”]Avdi Grimm, Code Cleric
Sometimes one instance is all you need.
httpv://youtube.com/watch?v=J6fgEFBeepY
[boilerplate bypath=”rubytapas-sample”]Comments are closed.
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
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.