Class: Protod::Proto::Service
Instance Method Summary
collapse
Methods inherited from Part
#ancestor_as, #has?, #ident=, #push, #root
Instance Method Details
#freeze ⇒ Object
22
23
24
25
26
27
28
29
|
# File 'lib/protod/proto/service.rb', line 22
def freeze
procedures.each { _1.depth = depth + 1 }
procedures.each.with_index(1) { |p, i| p.index = i }
@procedure_map = self.class.findable_keys_for(:procedure).index_with { |k| procedures.index_by(&k.to_sym) }
super
end
|
#pb_const ⇒ Object
18
19
20
|
# File 'lib/protod/proto/service.rb', line 18
def pb_const
parent.pb_const.const_get(ident).const_get('Service')
end
|
#ruby_ident ⇒ Object
14
15
16
|
# File 'lib/protod/proto/service.rb', line 14
def ruby_ident
ident.const_name
end
|
#to_proto ⇒ Object
31
32
33
34
35
36
37
38
39
|
# File 'lib/protod/proto/service.rb', line 31
def to_proto
procedure_part = procedures.map { _1.to_proto }.join("\n").presence
procedure_part = "\n#{procedure_part}\n" if procedure_part
[
format_proto("service %s {%s", ident, procedure_part),
format_proto("}")
].join
end
|