Skip to content
Snippets Groups Projects
Commit bae3a610 authored by Tim Emiola's avatar Tim Emiola
Browse files

Really removes the string monkey-patch

parent 13363e31
No related branches found
No related tags found
No related merge requests found
......@@ -468,10 +468,11 @@ module GRPC
route = "/#{cls.service_name}/#{name}".to_sym
fail "already registered: rpc #{route} from #{spec}" if specs.key? route
specs[route] = spec
rpc_name = GenericService.underscore(name.to_s).to_sym
if service.is_a?(Class)
handlers[route] = cls.new.method(name.to_s.underscore.to_sym)
handlers[route] = cls.new.method(rpc_name)
else
handlers[route] = service.method(name.to_s.underscore.to_sym)
handlers[route] = service.method(rpc_name)
end
logger.info("handling #{route} with #{handlers[route]}")
end
......
......@@ -30,24 +30,6 @@
require 'grpc/generic/client_stub'
require 'grpc/generic/rpc_desc'
# Extend String to add a method underscore
class String
# creates a new string that is the underscore separate version of this one.
#
# E.g,
# PrintHTML -> print_html
# AMethod -> a_method
# AnRpc -> an_rpc
def underscore
word = dup
word.gsub!(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
word.gsub!(/([a-z\d])([A-Z])/, '\1_\2')
word.tr!('-', '_')
word.downcase!
word
end
end
# GRPC contains the General RPC module.
module GRPC
# Provides behaviour used to implement schema-derived service classes.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment