Module: Singleton
- Defined in:
- lib/singleton.rb
Defined Under Namespace
Modules: SingletonClassMethods
Class Method Summary (collapse)
Instance Method Summary (collapse)
-
- (Object) _dump(depth = 1)
default marshalling strategy.
-
- (Object) clone
disable build-in copying methods.
- - (Object) dup
Class Method Details
+ (Object) __init__(klass)
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/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 |
Instance Method Details
- (Object) _dump(depth = 1)
default marshalling strategy
75 76 77 |
# File 'lib/singleton.rb', line 75 def _dump(depth = -1) '' end |
- (Object) clone
disable build-in copying methods
67 68 69 |
# File 'lib/singleton.rb', line 67 def clone raise TypeError, "can't clone instance of singleton #{self.class}" end |
- (Object) dup
70 71 72 |
# File 'lib/singleton.rb', line 70 def dup raise TypeError, "can't dup instance of singleton #{self.class}" end |