Module: Singleton
- Defined in:
- opal/stdlib/singleton.rb
Defined Under Namespace
Modules: SingletonClassMethods
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.__init__(klass) ⇒ Object
23
24
25
26
27
28
29
30
31
32
|
# File 'opal/stdlib/singleton.rb', line 23
def __init__(klass)
klass.instance_eval {
@singleton__instance__ = nil
}
def klass.instance
return @singleton__instance__ if @singleton__instance__
@singleton__instance__ = new()
end
klass
end
|
Instance Method Details
2
3
4
|
# File 'opal/stdlib/singleton.rb', line 2
def clone
raise TypeError, "can't clone instance of singleton #{self.class}"
end
|
6
7
8
|
# File 'opal/stdlib/singleton.rb', line 6
def dup
raise TypeError, "can't dup instance of singleton #{self.class}"
end
|