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.



12
13
14
15
# File 'lib/dizby/distributed/proxy.rb', line 12

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)



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/dizby/distributed/proxy.rb', line 17

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

  return result if succ
  fail result if result.is_a?(UnknownObject)

  bt = Dizby.proxy_backtrace(@conn.remote_uri, result)
  result.set_backtrace(bt + caller)
  fail result
end

Instance Method Details

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

Returns:

  • (Boolean)


33
34
35
# File 'lib/dizby/distributed/proxy.rb', line 33

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