Skip to content

Instantly share code, notes, and snippets.

@kopylovvlad
Created September 16, 2017 13:23
Show Gist options
  • Save kopylovvlad/16539f1ccb516205b7246676ee4f4a88 to your computer and use it in GitHub Desktop.
Save kopylovvlad/16539f1ccb516205b7246676ee4f4a88 to your computer and use it in GitHub Desktop.
class Database
@@instance = Database.new
def self.instance
return @@instance
end
private_class_method :new
end
d1 = Database.instance
d2 = Database.instance
d2.object_id == d1.object_id # true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment