class Sumac::RemoteObject

Public Class Methods

new(connection, remote_reference) click to toggle source
# File lib/sumac/remote_object.rb, line 4
def initialize(connection, remote_reference)
  raise "argument 'connection' must be a Connection" unless connection.is_a?(Connection)
  @connection = connection
  raise unless remote_reference.is_a?(RemoteReference)
  @remote_reference = remote_reference
end

Public Instance Methods

__remote_reference__() click to toggle source
# File lib/sumac/remote_object.rb, line 25
def __remote_reference__
  @remote_reference
end
forget() click to toggle source
# File lib/sumac/remote_object.rb, line 29
def forget
  @connection.mutex.synchronize { @remote_reference.local_forget_request }
  nil
end
inspect() click to toggle source
# File lib/sumac/remote_object.rb, line 34
def inspect
  "#<Sumac::RemoteObject:#{"0x00%x" % (object_id << 1)}>"
end
method_missing(method_name, *arguments, &block) click to toggle source
# File lib/sumac/remote_object.rb, line 11
def method_missing(method_name, *arguments, &block)  # blocks not working yet
  @connection.mutex.lock
  raise StaleObjectError unless @remote_reference.callable?
  begin
    arguments << block.to_lambda if block_given?
    return_value = @connection.call_dispatcher.make_call(self, method_name.to_s, arguments)
  rescue ClosedError
    raise StaleObjectError
  end
  return_value
ensure
  @connection.mutex.unlock if @connection.mutex.owned?
end