Class: DRb::DRbObject (Ruby 2.7.2)
Description: Class : DRb::DRbObject - Ruby 2.7.2

### Home Classes Methods

### In Files

- drb/drb.rb
- drb/eq.rb
- drb/gw.rb

### Parent

Object

### Methods

- ::_load
- ::new
- ::new_with
- ::new_with_uri
- #__drbref
- #__drburi
- #_dump
- #method_missing
- #respond_to?

### Class/Module Index

Quicksearch

- ACL
- ACL::ACLEntry
- ACL::ACLList
- DRb
- DRb::DRbArray
- DRb::DRbBadScheme
- DRb::DRbBadURI
- DRb::DRbConn
- DRb::DRbConnError
- DRb::DRbError
- DRb::DRbIdConv
- DRb::DRbIdConv
- DRb::DRbMessage
- DRb::DRbObject
- DRb::DRbObject
- DRb::DRbObservable
- DRb::DRbProtocol
- DRb::DRbRemoteError
- DRb::DRbSSLSocket
- DRb::DRbSSLSocket::SSLConfig
- DRb::DRbServerNotFound
- DRb::DRbTCPSocket
- DRb::DRbUNIXSocket
- DRb::DRbUndumped
- DRb::DRbUndumped
- DRb::DRbUnknown
- DRb::DRbUnknownError
- DRb::ExtServ
- DRb::ExtServManager
- DRb::GW
- DRb::GWIdConv
- DRb::Thread
- DRb::ThreadObject
- DRb::TimerIdConv
- DRb::TimerIdConv::TimerHolder2
- DRb::TimerIdConv::TimerHolder2::InvalidIndexError
- DRb::WeakIdConv
- DRb::WeakIdConv::WeakSet
- Object

No matching classes.

# DRb::DRbObject

Object wrapping a reference to a remote drb object.

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

### Public Class Methods

_load(s) click to toggle source

Unmarshall a marshalled DRbObject.

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

                   # File drb/drb.rb, line 1050
    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

new(obj, uri=nil) click to toggle source

Create a new remote object stub.

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

                   # File drb/drb.rb, line 1088
    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

new_with(uri, ref) click to toggle source

Creates a DRb::DRbObject given the reference information to the remote host `uri` and object `ref`.

                   # File drb/drb.rb, line 1064
    def self.new_with(uri, ref)
      it = self.allocate
      it.instance_variable_set(:@uri, uri)
      it.instance_variable_set(:@ref, ref)
      it
    end

new_with_uri(uri) click to toggle source

Create a new DRbObject from a URI alone.

                   # File drb/drb.rb, line 1072
    def self.new_with_uri(uri)
      self.new(nil, uri)
    end

### Public Instance Methods

__drbref() click to toggle source

Get the reference of the object, if local.

                   # File drb/drb.rb, line 1114
    def __drbref
      @ref
    end

__drburi() click to toggle source

Get the URI of the remote object.

                   # File drb/drb.rb, line 1109
    def __drburi
      @uri
    end

_dump(lv) click to toggle source

Marshall this object.

The URI and ref of the object are marshalled.

                   # File drb/drb.rb, line 1079
    def _dump(lv)
      Marshal.dump([@uri, @ref])
    end

method_missing(msg_id, *a, &b) click to toggle source

                   # File drb/drb.rb, line 1134
                   def method_missing(msg_id, *a, &b)
      if DRb.here?(@uri)
        obj = DRb.to_obj(@ref)
        DRb.current_server.check_insecure_method(obj, msg_id)
        return obj.__send__(msg_id, *a, &b)
      end

      succ, result = self.class.with_friend(@uri) do
        DRbConn.open(@uri) do |conn|
          conn.send_message(self, msg_id, a, b)
        end
      end

      if succ
        return result
      elsif DRbUnknown === result
        raise result
      else
        bt = self.class.prepare_backtrace(@uri, result)
        result.set_backtrace(bt + caller)
        raise result
      end
    end

respond_to?(msg_id, priv=false) click to toggle source

Routes respond_to? to the referenced remote object.

                   # File drb/drb.rb, line 1122
    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