Extended maintenance of Ruby versions 1.8.7 and 1.9.2 ended on July 31, 2014. Read more

In Files

  • singleton.rb

Class/Module Index [+]

Quicksearch

Singleton

Public Class Methods

__init__(klass) click to toggle source
 
               # File 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
            

Public Instance Methods

_dump(depth = -1) click to toggle source

default marshalling strategy

 
               # File singleton.rb, line 75
def _dump(depth = -1)
  ''
end
            
clone() click to toggle source

disable build-in copying methods

 
               # File singleton.rb, line 67
def clone
  raise TypeError, "can't clone instance of singleton #{self.class}"
end
            
dup() click to toggle source
 
               # File singleton.rb, line 70
def dup
  raise TypeError, "can't dup instance of singleton #{self.class}"
end