Name
Singleton — Singleton pattern module
Synopsis
The Singleton
module
allows the implementation of the Singleton design pattern. By
including the module, you can ensure that only one instance of a
class is created.
Required Library
require ’singleton’
Class Method
instance
Returns the only instance of the class. If an instance has already been created, it’s reused.
instance
is a class method added to classes that include theSingleton
module.
Get Ruby in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.