module Singleton
Public Class Methods
__init__(klass)
click to toggle source
# File lib/rubysl/singleton/singleton.rb, line 100 def __init__(klass) klass.instance_eval { @singleton__instance__ = nil @singleton__mutex__ = Mutex.new } def klass.instance return @singleton__instance__ if @singleton__instance__ @singleton__mutex__.synchronize { return @singleton__instance__ if @singleton__instance__ @singleton__instance__ = new() } @singleton__instance__ end klass end
Private Class Methods
append_features(mod)
click to toggle source
Calls superclass method
# File lib/rubysl/singleton/singleton.rb, line 121 def append_features(mod) # help out people counting on transitive mixins unless mod.instance_of?(Class) raise TypeError, "Inclusion of the OO-Singleton module in module #{mod}" end super end
included(klass)
click to toggle source
Calls superclass method
# File lib/rubysl/singleton/singleton.rb, line 129 def included(klass) super klass.private_class_method :new, :allocate klass.extend SingletonClassMethods Singleton.__init__(klass) end
Public Instance Methods
_dump(depth = -1)
click to toggle source
default marshalling strategy
# File lib/rubysl/singleton/singleton.rb, line 75 def _dump(depth = -1) '' end
clone()
click to toggle source
disable build-in copying methods
# File lib/rubysl/singleton/singleton.rb, line 67 def clone raise TypeError, "can't clone instance of singleton #{self.class}" end
dup()
click to toggle source
# File lib/rubysl/singleton/singleton.rb, line 70 def dup raise TypeError, "can't dup instance of singleton #{self.class}" end