Module: Singleton::SingletonClassMethods

Defined in:
lib/singleton.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#_load(str) ⇒ Object

By default calls instance(). Override to retain singleton state.


117
118
119
# File 'lib/singleton.rb', line 117

def _load(str)
  instance
end

#cloneObject

:nodoc:


112
113
114
# File 'lib/singleton.rb', line 112

def clone # :nodoc:
  Singleton.__init__(super)
end

#instanceObject

:nodoc:


121
122
123
124
125
126
127
128
# File 'lib/singleton.rb', line 121

def instance # :nodoc:
  return @singleton__instance__ if @singleton__instance__
  @singleton__mutex__.synchronize {
    return @singleton__instance__ if @singleton__instance__
    @singleton__instance__ = new()
  }
  @singleton__instance__
end