Skip to content

Instantly share code, notes, and snippets.

@SingularityMatrix
Last active August 29, 2015 14:20
Show Gist options
  • Save SingularityMatrix/165ebe0ebc09466832a6 to your computer and use it in GitHub Desktop.
Save SingularityMatrix/165ebe0ebc09466832a6 to your computer and use it in GitHub Desktop.
Using Ruby singleton library
require 'singleton'
class User
include singleton
end
>> User.instance
=> #<User:0x007fe75492fea8>
>> User.instance
=> #<User:0x007fe75492fea8>
User.new
# => NoMethodError: private method `new' called for User:Class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment