In Files

  • drb/weakidconv.rb

Parent

Methods

Included Modules

DRb::WeakIdConv::WeakSet

Public Class Methods

new() click to toggle source
 
               # File drb/weakidconv.rb, line 13
def initialize
  super()
  @immutable = {}
  @map = ObjectSpace::WeakMap.new
end
            

Public Instance Methods

add(obj) click to toggle source
 
               # File drb/weakidconv.rb, line 19
def add(obj)
  synchronize do
    begin
      @map[obj] = self
    rescue ArgumentError
      @immutable[obj.__id__] = obj
    end
    return obj.__id__
  end
end
            
fetch(ref) click to toggle source
 
               # File drb/weakidconv.rb, line 30
def fetch(ref)
  synchronize do
    @immutable.fetch(ref) {
      @map.each { |key, _|
        return key if key.__id__ == ref
      }
      raise RangeError.new("invalid reference")
    }
  end
end
            
There is an updated format of the API docs for this version here.