Class: XKoon::Proxy::Base

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

Overview

Object Proxy Base Class: Inherit this class to build proxy objects, routing all method calls to the remote peer.

Instance Method Summary collapse

Constructor Details

#initialize(peer, handler = XKoon::Handler) ⇒ Base

Construct: Creates a new Base proxy object around a given peer and optional handler.

Parameters:

  • peer (Hash)

    RxIO Peer (Client / Server) Hash

  • handler (Module) (defaults to: XKoon::Handler)

    Handler module



52
53
54
55
# File 'lib/xkoon/proxy.rb', line 52

def initialize peer, handler = XKoon::Handler
	@proxy_peer = peer
	@proxy_handler = handler
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object

Method Missing: Proxy all method calls into requests to the remote peer.



59
60
61
62
63
64
65
66
# File 'lib/xkoon/proxy.rb', line 59

def method_missing name, *args

	# Ensure we have at least a message
	raise "Missing argument in call to [#{name}] (msg)" unless args.size >= 1

	# Forward request through Proxy Module
	Proxy.send name, @proxy_peer, @proxy_handler, *args
end