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.
52 53 54 55 56 57 58 |
# File 'lib/gruf/controllers/request.rb', line 52 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.
25 26 27 |
# File 'lib/gruf/controllers/request.rb', line 25 def active_call @active_call end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
23 24 25 |
# File 'lib/gruf/controllers/request.rb', line 23 def @message end |
#method_key ⇒ Object (readonly)
Returns the value of attribute method_key.
27 28 29 |
# File 'lib/gruf/controllers/request.rb', line 27 def method_key @method_key end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
29 30 31 |
# File 'lib/gruf/controllers/request.rb', line 29 def type @type end |
Instance Method Details
#messages ⇒ Object
Return all messages for this request, properly handling different request types
84 85 86 87 88 89 90 91 92 |
# File 'lib/gruf/controllers/request.rb', line 84 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
75 76 77 |
# File 'lib/gruf/controllers/request.rb', line 75 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
66 67 68 |
# File 'lib/gruf/controllers/request.rb', line 66 def service_key @service.name.underscore.tr('/', '.').gsub('.service', '') end |