class DRb::DRbObject

object that this object is a stub for.
Method calls on this object are relayed to the remote
Object wrapping a reference to a remote drb object.

def self._load(s)

created to act as a stub for the remote referenced object.
the object itself is returned. Otherwise, a new DRbObject is
If the referenced object is located within the local server, then

Unmarshall a marshalled DRbObject.
def self._load(s)
  uri, ref = Marshal.load(s)
  if DRb.here?(uri)
    obj = DRb.to_obj(ref)
    return obj
  end
  self.new_with(uri, ref)
end

def self._load(s)

:nodoc:
def self._load(s)
  uri, ref = Marshal.load(s)
  if DRb.uri == uri
    return ref ? DRb.to_obj(ref) : DRb.front
  end
  self.new_with(DRb.uri, [:DRbObject, uri, ref])
end

def self.new_with(uri, ref)

def self.new_with(uri, ref)
  it = self.allocate
  it.instance_variable_set(:@uri, uri)
  it.instance_variable_set(:@ref, ref)
  it
end

def self.new_with_uri(uri)

Create a new DRbObject from a URI alone.
def self.new_with_uri(uri)
  self.new(nil, uri)
end

def self.prepare_backtrace(uri, result) # :nodoc:

:nodoc:
in the backtrace came from.
Returns a modified backtrace from +result+ with the +uri+ where each call
def self.prepare_backtrace(uri, result) # :nodoc:
  prefix = "(#{uri}) "
  bt = []
  result.backtrace.each do |x|
    break if /[`']__send__'$/ =~ x
    if /\A\(druby:\/\// =~ x
      bt.push(x)
    else
      bt.push(prefix + x)
    end
  end
  bt
end

def self.with_friend(uri) # :nodoc:

:nodoc:
Given the +uri+ of another host executes the block provided.
def self.with_friend(uri) # :nodoc:
  friend = DRb.fetch_server(uri)
  return yield() unless friend
  save = Thread.current['DRb']
  Thread.current['DRb'] = { 'server' => friend }
  return yield
ensure
  Thread.current['DRb'] = save if friend
end

def ==(other)

:nodoc:
def ==(other)
  return false unless DRbObject === other
 (@ref == other.__drbref) && (@uri == other.__drburi)
end

def __drbref

Get the reference of the object, if local.
def __drbref
  @ref
end

def __drburi

Get the URI of the remote object.
def __drburi
  @uri
end

def _dump(lv)

The URI and ref of the object are marshalled.

Marshall this object.
def _dump(lv)
  Marshal.dump([@uri, @ref])
end

def _dump(lv)

def _dump(lv)
  if DRb.uri == @uri
    if Array === @ref && @ref[0] == :DRbObject
      Marshal.dump([@ref[1], @ref[2]])
    else
      Marshal.dump([@uri, @ref]) # ??
    end
  else
    Marshal.dump([DRb.uri, [:DRbObject, @uri, @ref]])
  end
end

def hash

def hash
  [@uri, @ref].hash
end

def initialize(obj, uri=nil)

will be a stub for.
this is +nil+. +uri+ is the URI of the remote object that this
+obj+ is the (local) object we want to create a stub for. Normally

Create a new remote object stub.
def initialize(obj, uri=nil)
  @uri = nil
  @ref = nil
  case obj
  when Object
    is_nil = obj.nil?
  when BasicObject
    is_nil = false
  end
  if is_nil
    return if uri.nil?
    @uri, option = DRbProtocol.uri_option(uri, DRb.config)
    @ref = DRbURIOption.new(option) unless option.nil?
  else
    @uri = uri ? uri : (DRb.uri rescue nil)
    @ref = obj ? DRb.to_id(obj) : nil
  end
end

def method_missing(msg_id, *a, &b)

Routes method calls to the referenced remote object.
def method_missing(msg_id, *a, &b)
@uri)
o_obj(@ref)
_server.check_insecure_method(obj, msg_id)
__send__(msg_id, *a, &b)
= self.class.with_friend(@uri) do
n(@uri) do |conn|
_message(self, msg_id, a, b)
lt
own === result
t
lass.prepare_backtrace(@uri, result)
backtrace(bt + caller)
t

def pretty_print(q) # :nodoc:

:nodoc:
def pretty_print(q)   # :nodoc:
  q.pp_object(self)
end

def pretty_print_cycle(q) # :nodoc:

:nodoc:
def pretty_print_cycle(q)   # :nodoc:
  q.object_address_group(self) {
    q.breakable
    q.text '...'
  }
end

def respond_to?(msg_id, priv=false)

Routes respond_to? to the referenced remote object.
def respond_to?(msg_id, priv=false)
  case msg_id
  when :_dump
    true
  when :marshal_dump
    false
  else
    method_missing(:respond_to?, msg_id, priv)
  end
end