Class: Protod::Proto::Procedure
- Inherits:
-
Part
- Object
- Part
- Protod::Proto::Procedure
show all
- Defined in:
- lib/protod/proto/procedure.rb
Instance Method Summary
collapse
Methods inherited from Part
#ancestor_as, #freeze, #has?, #push, #root
Instance Method Details
#ident=(value) ⇒ Object
12
13
14
|
# File 'lib/protod/proto/procedure.rb', line 12
def ident=(value)
super(value.to_s.camelize)
end
|
#request_ident ⇒ Object
26
27
28
|
# File 'lib/protod/proto/procedure.rb', line 26
def request_ident
"#{ident}Request"
end
|
#response_ident ⇒ Object
30
31
32
|
# File 'lib/protod/proto/procedure.rb', line 30
def response_ident
"#{ident}Response"
end
|
#ruby_ident ⇒ Object
16
17
18
19
20
|
# File 'lib/protod/proto/procedure.rb', line 16
def ruby_ident
raise ArgumentError, "Not set parent" unless parent
Protod::RubyIdent.new(const_name: parent.ruby_ident, method_name: ruby_method_name, singleton: singleton)
end
|
#ruby_method_name ⇒ Object
22
23
24
|
# File 'lib/protod/proto/procedure.rb', line 22
def ruby_method_name
ident.underscore
end
|
#to_proto ⇒ Object
34
35
36
37
38
39
|
# File 'lib/protod/proto/procedure.rb', line 34
def to_proto
request_part = format("%s%s", streaming_request ? 'stream ' : '', has_request ? request_ident : '')
response_part = format("%s%s", streaming_response ? 'stream ' : '', has_response ? response_ident : '')
format_proto("rpc %s (%s) returns (%s);", ident, request_part, response_part)
end
|