Sha256: 31cf26c9128c103b5f92c14d1b91df550c6acf6fc421dbde4dec25e9dc552e7f
Contents?: true
Size: 1.08 KB
Versions: 1
Compression:
Stored size: 1.08 KB
Contents
# frozen_string_literal: true class Protod module Proto class Service < Part include Findable attribute :procedures, default: -> { [] } findable_callback_for(:procedure, key: %i[ident ruby_ident ruby_method_name]) do |key, value| @procedure_map ? @procedure_map.fetch(key)[value] : procedures.find { _1.public_send(key) == value } end def ruby_ident ident.const_name end def pb_const parent.pb_const.const_get(ident).const_get('Service') end 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 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 end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
protod-0.1.0 | lib/protod/proto/service.rb |