Class: Gritz::MethodDescriptor
- Inherits:
-
Object
- Object
- Gritz::MethodDescriptor
- Defined in:
- /home/runner/work/gritz/gritz/sources/gritz-core/lib/gritz/method_descriptor.rb
Overview
Immutable route and protobuf type information for one RPC.
Instance Attribute Summary collapse
- #action ⇒ Object readonly
- #controller ⇒ Object readonly
- #input_type ⇒ Object readonly
- #name ⇒ Object readonly
- #output_type ⇒ Object readonly
- #service ⇒ Object readonly
- #service_class ⇒ Object readonly
Instance Method Summary collapse
- #client_streaming? ⇒ Boolean
- #full_name ⇒ Object
-
#initialize(service:, name:, input_type:, output_type:, client_streaming: false, server_streaming: false, controller: nil, service_class: nil) ⇒ MethodDescriptor
constructor
A new instance of MethodDescriptor.
- #kind ⇒ Object
- #server_streaming? ⇒ Boolean
Constructor Details
#initialize(service:, name:, input_type:, output_type:, client_streaming: false, server_streaming: false, controller: nil, service_class: nil) ⇒ MethodDescriptor
Returns a new instance of MethodDescriptor.
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File '/home/runner/work/gritz/gritz/sources/gritz-core/lib/gritz/method_descriptor.rb', line 9 def initialize(service:, name:, input_type:, output_type:, client_streaming: false, server_streaming: false, controller: nil, service_class: nil) @service = service.to_s @name = name.to_s @input_type = input_type @output_type = output_type @client_streaming = client_streaming @server_streaming = server_streaming @controller = controller @service_class = service_class @action = @name.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').gsub(/([a-z\d])([A-Z])/, '\1_\2').downcase.to_sym freeze end |
Instance Attribute Details
#action ⇒ Object (readonly)
7 8 9 |
# File '/home/runner/work/gritz/gritz/sources/gritz-core/lib/gritz/method_descriptor.rb', line 7 def action @action end |
#controller ⇒ Object (readonly)
7 8 9 |
# File '/home/runner/work/gritz/gritz/sources/gritz-core/lib/gritz/method_descriptor.rb', line 7 def controller @controller end |
#input_type ⇒ Object (readonly)
7 8 9 |
# File '/home/runner/work/gritz/gritz/sources/gritz-core/lib/gritz/method_descriptor.rb', line 7 def input_type @input_type end |
#name ⇒ Object (readonly)
7 8 9 |
# File '/home/runner/work/gritz/gritz/sources/gritz-core/lib/gritz/method_descriptor.rb', line 7 def name @name end |
#output_type ⇒ Object (readonly)
7 8 9 |
# File '/home/runner/work/gritz/gritz/sources/gritz-core/lib/gritz/method_descriptor.rb', line 7 def output_type @output_type end |
#service ⇒ Object (readonly)
7 8 9 |
# File '/home/runner/work/gritz/gritz/sources/gritz-core/lib/gritz/method_descriptor.rb', line 7 def service @service end |
#service_class ⇒ Object (readonly)
7 8 9 |
# File '/home/runner/work/gritz/gritz/sources/gritz-core/lib/gritz/method_descriptor.rb', line 7 def service_class @service_class end |
Instance Method Details
#client_streaming? ⇒ Boolean
24 |
# File '/home/runner/work/gritz/gritz/sources/gritz-core/lib/gritz/method_descriptor.rb', line 24 def client_streaming? = @client_streaming |
#full_name ⇒ Object
23 |
# File '/home/runner/work/gritz/gritz/sources/gritz-core/lib/gritz/method_descriptor.rb', line 23 def full_name = "/#{service}/#{name}" |
#kind ⇒ Object
27 28 29 30 31 32 33 |
# File '/home/runner/work/gritz/gritz/sources/gritz-core/lib/gritz/method_descriptor.rb', line 27 def kind return :bidi if client_streaming? && server_streaming? return :client_streaming if client_streaming? return :server_streaming if server_streaming? :unary end |
#server_streaming? ⇒ Boolean
25 |
# File '/home/runner/work/gritz/gritz/sources/gritz-core/lib/gritz/method_descriptor.rb', line 25 def server_streaming? = @server_streaming |