Class: Connect::Client
Instance Attribute Summary collapse
-
#transport ⇒ Object
readonly
Returns the value of attribute transport.
Class Method Summary collapse
Instance Method Summary collapse
- #call(method:, input:, header: {}, trailer: {}) ⇒ Object
-
#initialize(transport:) ⇒ Client
constructor
A new instance of Client.
- #service ⇒ Object
Methods included from DSL
on_rpc_method_added, rpc, rpcs, service=
Constructor Details
#initialize(transport:) ⇒ Client
Returns a new instance of Client.
17 18 19 |
# File 'lib/connect/client.rb', line 17 def initialize(transport:) @transport = transport end |
Instance Attribute Details
#transport ⇒ Object (readonly)
Returns the value of attribute transport.
15 16 17 |
# File 'lib/connect/client.rb', line 15 def transport @transport end |
Class Method Details
.on_rpc_method_added(method) ⇒ Object
8 9 10 11 12 |
# File 'lib/connect/client.rb', line 8 def on_rpc_method_added(method) define_method(method.ruby_method) do |input, header: {}, trailer: {}| call(method: method, input: input, header: header, trailer: trailer) end end |
Instance Method Details
#call(method:, input:, header: {}, trailer: {}) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/connect/client.rb', line 21 def call(method:, input:, header: {}, trailer: {}) if method.unary? transport.unary(service: service, method: method, input: input, header: header, trailer: trailer) elsif method.stream? transport.stream(service: service, method: method, input: input, header: header, trailer: trailer) else raise UnknownMethodError, "Unknown method type: #{method.class}" end end |
#service ⇒ Object
31 32 33 |
# File 'lib/connect/client.rb', line 31 def service self.class.service end |