Last active
August 29, 2015 14:20
-
-
Save SingularityMatrix/165ebe0ebc09466832a6 to your computer and use it in GitHub Desktop.
Using Ruby singleton library
This file contains hidden or 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 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