Class: Protobuf::Generators::ServiceGenerator

Inherits:
Base
  • Object
show all
Defined in:
lib/protobuf/generators/service_generator.rb

Constant Summary

Constants included from Printable

Printable::PARENT_CLASS_ENUM, Printable::PARENT_CLASS_MESSAGE, Printable::PARENT_CLASS_SERVICE

Instance Attribute Summary

Attributes inherited from Base

#descriptor, #namespace, #options

Instance Method Summary collapse

Methods inherited from Base

#fully_qualified_type_namespace, #initialize, #run_once, #to_s, #type_namespace, validate_tags

Methods included from Printable

#init_printer

Constructor Details

This class inherits a constructor from Protobuf::Generators::Base

Instance Method Details

#build_method(method_descriptor) ⇒ Object



17
18
19
20
21
22
# File 'lib/protobuf/generators/service_generator.rb', line 17

def build_method(method_descriptor)
  name = method_descriptor.name
  request_klass = modulize(method_descriptor.input_type)
  response_klass = modulize(method_descriptor.output_type)
  "rpc :#{name.underscore}, #{request_klass}, #{response_klass}"
end

#compileObject



7
8
9
10
11
12
13
14
15
# File 'lib/protobuf/generators/service_generator.rb', line 7

def compile
  run_once(:compile) do
    print_class(descriptor.name, :service) do
      descriptor.method.each do |method_descriptor|
        puts build_method(method_descriptor)
      end
    end
  end
end