Class: Barrister::InterfaceProxy
- Inherits:
-
Object
- Object
- Barrister::InterfaceProxy
- Defined in:
- lib/barrister.rb
Overview
Internal class used by the Client and BatchClient classes
Each instance represents a proxy for a single interface in the IDL, and will contain a method for each function in the interface.
These proxy methods call ‘Client.request` when invoked
Instance Method Summary collapse
-
#initialize(client, iface) ⇒ InterfaceProxy
constructor
A new instance of InterfaceProxy.
Constructor Details
#initialize(client, iface) ⇒ InterfaceProxy
Returns a new instance of InterfaceProxy.
545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 |
# File 'lib/barrister.rb', line 545 def initialize(client, iface) singleton = class << self; self end iface.functions.each do |f| method = iface.name + "." + f.name singleton.send :define_method, f.name do |*args| resp = client.request(method, args) if client.trans.instance_of? BatchTransport return nil else if resp.key?("result") return resp["result"] else err = resp["error"] raise RpcException.new(err["code"], err["message"], err["data"]) end end end end end |