Sha256: 83a6225f99e7c9bb8e31c01771514f91e6ee3129822570b080b3ae9324bd5762

Contents?: true

Size: 737 Bytes

Versions: 5

Compression:

Stored size: 737 Bytes

Contents

require 'protobuf/generators/base'

module Protobuf
  module Generators
    class ServiceGenerator < Base

      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

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

    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
protobuffy-4.0.1 lib/protobuf/generators/service_generator.rb
protobuffy-4.0.0 lib/protobuf/generators/service_generator.rb
protobuf-3.7.0.pre2 lib/protobuf/generators/service_generator.rb
protobuf-3.7.0.pre1 lib/protobuf/generators/service_generator.rb
protobuf-3.7.0.pre0 lib/protobuf/generators/service_generator.rb