Class: Dizby::ObjectProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/dizby/distributed/proxy.rb

Instance Method Summary collapse

Constructor Details

#initialize(conn, ref = nil) ⇒ ObjectProxy

Returns a new instance of ObjectProxy.


6
7
8
9
# File 'lib/dizby/distributed/proxy.rb', line 6

def initialize(conn, ref = nil)
  @ref = ref
  @conn = conn
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(msg_id, *args, &block)


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/dizby/distributed/proxy.rb', line 11

def method_missing(msg_id, *args, &block)
  @conn.server.log.debug("calling through proxy: #{msg_id} #{args}")
  @conn.send_request(@ref, msg_id, *args, &block)
  succ, result = @conn.recv_reply

  if succ
    result
  elsif result.is_a?(UnknownObject)
    fail result
  else
    bt = Dizby.proxy_backtrace(@conn.remote_uri, result)
    result.set_backtrace(bt + caller)
    fail result
  end
end

Instance Method Details

#respond_to?(msg_id, priv = false) ⇒ Boolean

Returns:

  • (Boolean)

30
31
32
# File 'lib/dizby/distributed/proxy.rb', line 30

def respond_to?(msg_id, priv = false)
  method_missing(:respond_to?, msg_id, priv)
end