Created
September 22, 2018 13:02
-
-
Save rakesh87/532f76e98def20b9367bb5576096c90b to your computer and use it in GitHub Desktop.
global config object to store shared variables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# minimal example for singleton pattern | |
class Configs | |
class << self | |
def instance | |
@instance ||= new | |
end | |
private :new | |
end | |
end | |
# using singleton module | |
require 'singleton' | |
class Config | |
include Singleton | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment