require 'singleton'
class MySingletonClass
include Singleton
end
MySingletonClass.instance #=> the singleton instance
MySingletonClass.new #=> NoMethodError
I love dynamic languages.
See Ruby’s Singleton
module for more information.
2012-09-13 programming ruby singleton patterns
require 'singleton'
class MySingletonClass
include Singleton
end
MySingletonClass.instance #=> the singleton instance
MySingletonClass.new #=> NoMethodError
I love dynamic languages.
See Ruby’s Singleton
module for more information.