123456789_123456789_123456789_123456789_123456789_

Module: Singleton::SingletonClassMethods

Do not use. This module is for internal use only.
Relationships & Source Files
Defined in: lib/singleton.rb

Instance Method Summary

Instance Method Details

#_load(str)

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

[ GitHub ]

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

def _load(str)
  instance
end

#clone

[ GitHub ]

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

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

#inherited(sub_klass) (private)

[ GitHub ]

  
# File 'lib/singleton.rb', line 132

def inherited(sub_klass)
  super
  Singleton.__init__(sub_klass)
end

#instance

[ GitHub ]

  
# 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