Module: GRPC::GenericService

Overview

Provides behaviour used to implement schema-derived service classes.

Is intended to be used to support both client and server IDL-schema-derived servers.

Defined Under Namespace

Modules: Dsl Classes: DuplicateRpcName

Class Method Summary collapse

Class Method Details

.included(o) ⇒ Object


217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
# File 'src/ruby/lib/grpc/generic/service.rb', line 217

def self.included(o)
  o.extend(Dsl)
  # Update to the use the service name including module. Provide a default
  # that can be nil e.g. when modules are declared dynamically.
  return unless o.service_name.nil?
  if o.name.nil?
    o.service_name = 'GenericService'
  else
    modules = o.name.split('::')
    if modules.length > 2
      o.service_name = modules[modules.length - 2]
    else
      o.service_name = modules.first
    end
  end
end

.underscore(s) ⇒ Object

creates a new string that is the underscore separate version of s.

E.g, PrintHTML -> print_html AMethod -> a_method AnRpc -> an_rpc

Parameters:

  • s (String)

    the string to be converted.


48
49
50
51
52
53
54
# File 'src/ruby/lib/grpc/generic/service.rb', line 48

def self.underscore(s)
  s.gsub!(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
  s.gsub!(/([a-z\d])([A-Z])/, '\1_\2')
  s.tr!('-', '_')
  s.downcase!
  s
end