Class: Arachni::RPC::RemoteObjectMapper
- Defined in:
- lib/arachni/rpc/remote_object_mapper.rb
Overview
Maps the methods of remote objects to local ones. (Well, not really, it just passes the message along to the remote end.)
You start like:
server = Arachni::RPC::EM::Client.new( :host => 'localhost', :port => 7331 )
bench = Arachni::RPC::EM::Client::Mapper.new( server, 'bench' )
And it allows you to do this:
res = bench.foo( 1, 2, 3 )
Instead of:
res = client.call( 'bench.foo', 1, 2, 3 )
The server on the other end must have an appropriate handler set, like:
class Bench
def foo( i = 0 )
return i
end
end
server = Arachni::RPC::EM::Server.new( :host => 'localhost', :port => 7331 )
server.add_handler( 'bench', Bench.new )
@author: Tasos “Zapotek” Laskos <[email protected]>
Instance Method Summary collapse
-
#initialize(server, remote) ⇒ RemoteObjectMapper
constructor
A new instance of RemoteObjectMapper.
Constructor Details
#initialize(server, remote) ⇒ RemoteObjectMapper
Returns a new instance of RemoteObjectMapper.
48 49 50 51 |
# File 'lib/arachni/rpc/remote_object_mapper.rb', line 48 def initialize( server, remote ) @server = server @remote = remote end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object (private)
Used to provide the illusion of locality for remote methods
57 58 59 60 |
# File 'lib/arachni/rpc/remote_object_mapper.rb', line 57 def method_missing( sym, *args, &block ) call = "#{@remote}.#{sym.to_s}" @server.call( call, *args, &block ) end |