Class: Ribbon::Intercom::Client::SDK
- Inherits:
-
Object
- Object
- Ribbon::Intercom::Client::SDK
- Includes:
- Utils::Mixins::MockSafe
- Defined in:
- lib/ribbon/intercom/client/sdk.rb,
lib/ribbon/intercom/client/sdk/adapters.rb
Direct Known Subclasses
Defined Under Namespace
Modules: Adapters
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
Instance Method Summary collapse
- #begin ⇒ Object
-
#call(method_name, *args) ⇒ Object
Calls the method on the adapter returning the response Packet.
- #connect(*args) ⇒ Object
- #connected? ⇒ Boolean
- #dup ⇒ Object
-
#headers(new_headers = {}) ⇒ Object
Returns the headers defined for this SDK.
-
#initialize(*args) ⇒ SDK
constructor
A new instance of SDK.
-
#send_packet(packet) ⇒ Object
Sends the packet with the adapter, returning the response Packet.
Methods included from Utils::Mixins::MockSafe
#mock_safe, #mock_safe!, #mock_safe?
Constructor Details
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object (private)
Simulates calling the remote method as if it were a local method.
Intended to be called by end-users.
78 79 80 |
# File 'lib/ribbon/intercom/client/sdk.rb', line 78 def method_missing(meth, *args, &block) call(meth, *args).retval end |
Instance Attribute Details
#adapter ⇒ Object
Returns the value of attribute adapter.
10 11 12 |
# File 'lib/ribbon/intercom/client/sdk.rb', line 10 def adapter @adapter end |
Instance Method Details
#begin ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/ribbon/intercom/client/sdk.rb', line 21 def begin Utils::MethodChain.begin { |methods| queue = Packet::MethodQueue.new methods.each { |meth, *args| queue.enqueue(meth, *args) } send_packet(method_queue: queue).retval } end |
#call(method_name, *args) ⇒ Object
Calls the method on the adapter returning the response Packet
46 47 48 49 50 |
# File 'lib/ribbon/intercom/client/sdk.rb', line 46 def call(method_name, *args) send_packet( method_queue: Packet::MethodQueue.new.enqueue(method_name, *args) ) end |
#connect(*args) ⇒ Object
36 37 38 |
# File 'lib/ribbon/intercom/client/sdk.rb', line 36 def connect(*args) adapter.connect(*args) end |
#connected? ⇒ Boolean
40 41 42 |
# File 'lib/ribbon/intercom/client/sdk.rb', line 40 def connected? adapter.connected? end |
#dup ⇒ Object
60 61 62 63 64 |
# File 'lib/ribbon/intercom/client/sdk.rb', line 60 def dup super.tap { |sdk| sdk.adapter = adapter.dup } end |
#headers(new_headers = {}) ⇒ Object
Returns the headers defined for this SDK. Optionally, you may also define additional headers you’d like to add/override.
32 33 34 |
# File 'lib/ribbon/intercom/client/sdk.rb', line 32 def headers(new_headers={}) adapter.headers(new_headers) end |
#send_packet(packet) ⇒ Object
Sends the packet with the adapter, returning the response Packet.
Intended to be called by Package.
56 57 58 |
# File 'lib/ribbon/intercom/client/sdk.rb', line 56 def send_packet(packet) _process_response(adapter.send_packet(packet)) end |