Class: Gruf::Controllers::Request
- Inherits:
-
Object
- Object
- Gruf::Controllers::Request
- Defined in:
- lib/gruf/controllers/request.rb
Overview
Encapsulates a request for a controller
Defined Under Namespace
Classes: Type
Instance Attribute Summary collapse
-
#active_call ⇒ Object
readonly
Returns the value of attribute active_call.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#method_key ⇒ Object
readonly
Returns the value of attribute method_key.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(method_key:, service:, rpc_desc:, active_call:, message:) ⇒ Request
constructor
A new instance of Request.
-
#messages ⇒ Object
Return all messages for this request, properly handling different request types.
-
#method_name ⇒ String
Parse the method signature into a service.method name format.
-
#service_key ⇒ String
Returns the service name as a translated name separated by periods.
Constructor Details
#initialize(method_key:, service:, rpc_desc:, active_call:, message:) ⇒ Request
Returns a new instance of Request.
53 54 55 56 57 58 59 |
# File 'lib/gruf/controllers/request.rb', line 53 def initialize(method_key:, service:, rpc_desc:, active_call:, message:) @method_key = method_key @service = service @active_call = active_call @message = @type = Type.new(rpc_desc) end |
Instance Attribute Details
#active_call ⇒ Object (readonly)
Returns the value of attribute active_call.
26 27 28 |
# File 'lib/gruf/controllers/request.rb', line 26 def active_call @active_call end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
24 25 26 |
# File 'lib/gruf/controllers/request.rb', line 24 def @message end |
#method_key ⇒ Object (readonly)
Returns the value of attribute method_key.
28 29 30 |
# File 'lib/gruf/controllers/request.rb', line 28 def method_key @method_key end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
30 31 32 |
# File 'lib/gruf/controllers/request.rb', line 30 def type @type end |
Instance Method Details
#messages ⇒ Object
Return all messages for this request, properly handling different request types
85 86 87 88 89 90 91 92 93 |
# File 'lib/gruf/controllers/request.rb', line 85 def if client_streamer? .call { |msg| yield msg } elsif bidi_streamer? else [] end end |
#method_name ⇒ String
Parse the method signature into a service.method name format
76 77 78 |
# File 'lib/gruf/controllers/request.rb', line 76 def method_name "#{service_key}.#{method_key}" end |
#service_key ⇒ String
Returns the service name as a translated name separated by periods. Strips the superfluous “Service” suffix from the name
67 68 69 |
# File 'lib/gruf/controllers/request.rb', line 67 def service_key @service.name.underscore.tr('/', '.').gsub('.service', '') end |