Class: ASIR::Client::Proxy
- Inherits:
-
Object
- Object
- ASIR::Client::Proxy
- Defined in:
- lib/asir/client.rb
Overview
!SLIDE Client Proxy
Provide client interface proxy to a service.
Instance Attribute Summary collapse
-
#__configure ⇒ Object
A Proc to call with the Message object before sending to transport#send_message(message).
-
#_one_way ⇒ Object
If true, this Message is one-way, even if the Transport is bi-directional.
-
#before_send_message ⇒ Object
A Proc to call with the Message object before sending to transport#send_message(message).
-
#receiver ⇒ Object
Returns the value of attribute receiver.
-
#receiver_class ⇒ Object
Returns the value of attribute receiver_class.
-
#transport ⇒ Object
!SLIDE Client Transport.
Class Method Summary collapse
Instance Method Summary collapse
-
#_configure(&blk) ⇒ Object
(also: #_options)
Returns a new Client Proxy with a block to be called with the Message.
- #_configure! ⇒ Object
-
#initialize(rcvr, rcvr_class) ⇒ Proxy
constructor
!SLIDE Configuration Callbacks.
-
#send(selector, *arguments, &block) ⇒ Object
(also: #method_missing)
Accept messages as a proxy for the receiver.
Constructor Details
#initialize(rcvr, rcvr_class) ⇒ Proxy
!SLIDE Configuration Callbacks
101 102 103 104 105 |
# File 'lib/asir/client.rb', line 101 def initialize rcvr, rcvr_class @receiver = rcvr @receiver_class = rcvr_class _configure! end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing ⇒ Object
Accept messages as a proxy for the receiver. Blocks are used represent a “continuation” for the Result. Accept all other messages to be encoded and transported to a service.
60 61 62 63 64 65 |
# File 'lib/asir/client.rb', line 60 def send selector, *arguments, &block = Message.new(@receiver, selector, arguments, block, self) = .call() if @__configure.call(, self) if @__configure transport.() # => result end |
Instance Attribute Details
#__configure ⇒ Object
A Proc to call with the Message object before sending to transport#send_message(message). See #_configure.
82 83 84 |
# File 'lib/asir/client.rb', line 82 def __configure @__configure end |
#_one_way ⇒ Object
If true, this Message is one-way, even if the Transport is bi-directional.
78 79 80 |
# File 'lib/asir/client.rb', line 78 def _one_way @_one_way end |
#before_send_message ⇒ Object
A Proc to call with the Message object before sending to transport#send_message(message). Must return a Message object.
75 76 77 |
# File 'lib/asir/client.rb', line 75 def end |
#receiver ⇒ Object
Returns the value of attribute receiver.
49 50 51 |
# File 'lib/asir/client.rb', line 49 def receiver @receiver end |
#receiver_class ⇒ Object
Returns the value of attribute receiver_class.
49 50 51 |
# File 'lib/asir/client.rb', line 49 def receiver_class @receiver_class end |
#transport ⇒ Object
!SLIDE Client Transport
64 65 66 |
# File 'lib/asir/client.rb', line 64 def transport @transport end |
Class Method Details
.config_callbacks ⇒ Object
117 118 119 |
# File 'lib/asir/client.rb', line 117 def self.config_callbacks @@config_callbacks end |
Instance Method Details
#_configure(&blk) ⇒ Object Also known as: _options
Returns a new Client Proxy with a block to be called with the Message. This block can configure additional options of the Message before it is sent to the Transport.
Call sequence:
proxy.__configure.call(, proxy).
91 92 93 94 95 |
# File 'lib/asir/client.rb', line 91 def _configure &blk proxy = @receiver == @receiver_class ? self.dup : self proxy.__configure = blk proxy end |
#_configure! ⇒ Object
107 108 109 110 111 112 113 114 |
# File 'lib/asir/client.rb', line 107 def _configure! key = @receiver_class (@@config_callbacks[key] || @@config_callbacks[key.name] || @@config_callbacks[nil] || IDENTITY_LAMBDA).call(self) self end |
#send(selector, *arguments, &block) ⇒ Object Also known as: method_missing
Accept messages as a proxy for the receiver. Blocks are used represent a “continuation” for the Result.
53 54 55 56 57 58 |
# File 'lib/asir/client.rb', line 53 def send selector, *arguments, &block = Message.new(@receiver, selector, arguments, block, self) = .call() if @__configure.call(, self) if @__configure transport.() # => result end |