Skip to content

Files

Latest commit

Sep 29, 2021
8423ae0 · Sep 29, 2021

History

History

singleton

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Sep 29, 2021
Oct 18, 2019
Oct 18, 2019

Singleton pattern using Modulation

One of the most common programming patterns in Ruby is the singleton pattern, which is especially useful when writing in a more functional style. Modulation makes it easier to write singletons by treating source-file as singleton modules by default. Thus, any method defined in such a module is a singleton method. This reduces the boilerplate usually involved in writing Ruby singelton to the bare minimum.

In the present example, the imported module is a singleton implementing the interface expected by the application.