Class: DRb::DRbObjectSpace

Inherits:
Object
  • Object
show all
Includes:
MonitorMixin
Defined in:
lib/drb/drb.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initializeDRbObjectSpace

Returns a new instance of DRbObjectSpace.



357
358
359
360
# File 'lib/drb/drb.rb', line 357

def initialize
  super()
  @map = ObjectSpace::WeakMap.new
end

Instance Method Details

#to_id(obj) ⇒ Object



362
363
364
365
366
367
# File 'lib/drb/drb.rb', line 362

def to_id(obj)
  synchronize do
    @map[obj.__id__] = obj
    obj.__id__
  end
end

#to_obj(ref) ⇒ Object



369
370
371
372
373
374
375
# File 'lib/drb/drb.rb', line 369

def to_obj(ref)
  synchronize do
    obj = @map[ref]
    raise RangeError.new("invalid reference") unless obj.__id__ == ref
    obj
  end
end