-
-
Save mehdi-farsi/135d516254ae690335da0b14c13ed83b to your computer and use it in GitHub Desktop.
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
require 'singleton' | |
class Client | |
include Singleton | |
attr_accessor :url, :port, :credentials | |
end | |
class DBClient < Client; end | |
class ApiClient < Client; end | |
db = DBClient.instance | |
db.url = 'https://10.11.12.13' | |
db.port = 4242 | |
db.credentials = 'username:password' | |
api = ApiClient.instance | |
p api.url # => nil | |
p api.port # => nil | |
p api.credentials # => nil | |
api.url = 'https://14.15.16.17' | |
api.port = 8484 | |
api.credentials = 'username:password' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment