Class: Marvin::Distributed::Client::RemoteClientProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/marvin/distributed/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(conn, host_with_port, nickname) ⇒ RemoteClientProxy

Returns a new instance of RemoteClientProxy.



15
16
17
18
19
# File 'lib/marvin/distributed/client.rb', line 15

def initialize(conn, host_with_port, nickname)
  @connection     = conn
  @host_with_port = host_with_port
  @nickname       = nickname
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/marvin/distributed/client.rb', line 29

def method_missing(name, *args)
  logger.debug "Proxying #{name}(#{args.inspect[1..-2]}) to #{@host_with_port}"
  @connection.send_message(:action, {
    "action"      => name.to_s,
    "arguments"   => args,
    "client-host" => @host_with_port
  })
end

Instance Method Details

#host_with_portObject



25
26
27
# File 'lib/marvin/distributed/client.rb', line 25

def host_with_port
  @host_with_port
end

#nicknameObject



21
22
23
# File 'lib/marvin/distributed/client.rb', line 21

def nickname
  @nickname
end