Class: Connect::Method
- Inherits:
-
Object
show all
- Defined in:
- lib/connect/method.rb
Defined Under Namespace
Classes: Stream, Type, Unary
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(name:, request_type:, response_type:, ruby_method:) ⇒ Method
51
52
53
54
55
56
|
# File 'lib/connect/method.rb', line 51
def initialize(name:, request_type:, response_type:, ruby_method:)
@name = name
@request_type = request_type
@response_type = response_type
@ruby_method = ruby_method
end
|
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
49
50
51
|
# File 'lib/connect/method.rb', line 49
def name
@name
end
|
#request_type ⇒ Object
Returns the value of attribute request_type.
49
50
51
|
# File 'lib/connect/method.rb', line 49
def request_type
@request_type
end
|
#response_type ⇒ Object
Returns the value of attribute response_type.
49
50
51
|
# File 'lib/connect/method.rb', line 49
def response_type
@response_type
end
|
#ruby_method ⇒ Object
Returns the value of attribute ruby_method.
49
50
51
|
# File 'lib/connect/method.rb', line 49
def ruby_method
@ruby_method
end
|
Instance Method Details
#==(other) ⇒ Object
83
84
85
86
87
88
89
|
# File 'lib/connect/method.rb', line 83
def ==(other)
other.is_a?(Method) &&
name == other.name &&
request_type == other.request_type &&
response_type == other.response_type &&
ruby_method == other.ruby_method
end
|
#bidi_stream? ⇒ Boolean
66
67
68
|
# File 'lib/connect/method.rb', line 66
def bidi_stream?
request_type.stream? && response_type.stream?
end
|
#decode_response(input, max_bytes:) ⇒ Object
77
78
79
80
81
|
# File 'lib/connect/method.rb', line 77
def decode_response(input, max_bytes:)
raise MaxBytesExceededError, "Response exceeded maximum size of #{max_bytes} bytes" if input.bytesize > max_bytes
response_type.decode(input)
end
|
#encode_request(input, max_bytes:) ⇒ Object
70
71
72
73
74
75
|
# File 'lib/connect/method.rb', line 70
def encode_request(input, max_bytes:)
output = request_type.encode(input)
raise MaxBytesExceededError, "Request exceeded maximum size of #{max_bytes} bytes" if output.bytesize > max_bytes
output
end
|
#inspect ⇒ Object
91
92
93
|
# File 'lib/connect/method.rb', line 91
def inspect
"#<#{self.class.name} name=#{name.inspect} request_type=#{request_type.inspect} response_type=#{response_type.inspect} ruby_method=#{ruby_method.inspect}>"
end
|
#stream? ⇒ Boolean
62
63
64
|
# File 'lib/connect/method.rb', line 62
def stream?
request_type.stream? || response_type.stream?
end
|
#unary? ⇒ Boolean
58
59
60
|
# File 'lib/connect/method.rb', line 58
def unary?
request_type.unary? && response_type.unary?
end
|