diff options
author | Tim Emiola <temiola@google.com> | 2015-05-07 14:24:23 -0700 |
---|---|---|
committer | Tim Emiola <temiola@google.com> | 2015-05-07 14:24:23 -0700 |
commit | bae3a61087d5ff4d5f25c1d6b4881e0f46c034c7 (patch) | |
tree | 225f8463557399b9fef92b8dfbe476733cadb9ee /src/ruby/lib | |
parent | 13363e31a749fbe5065d66383a0acecbe5ab02fe (diff) |
Really removes the string monkey-patch
Diffstat (limited to 'src/ruby/lib')
-rw-r--r-- | src/ruby/lib/grpc/generic/rpc_server.rb | 5 | ||||
-rw-r--r-- | src/ruby/lib/grpc/generic/service.rb | 18 |
2 files changed, 3 insertions, 20 deletions
diff --git a/src/ruby/lib/grpc/generic/rpc_server.rb b/src/ruby/lib/grpc/generic/rpc_server.rb index 3375fcf20a..424719304e 100644 --- a/src/ruby/lib/grpc/generic/rpc_server.rb +++ b/src/ruby/lib/grpc/generic/rpc_server.rb @@ -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 diff --git a/src/ruby/lib/grpc/generic/service.rb b/src/ruby/lib/grpc/generic/service.rb index 2226820c2b..8ea2c82f17 100644 --- a/src/ruby/lib/grpc/generic/service.rb +++ b/src/ruby/lib/grpc/generic/service.rb @@ -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. |