Avoid more monkey-patching

This commit is contained in:
xhh 2015-06-26 16:04:18 +08:00
parent 327128dbba
commit 0ac1ef266f
4 changed files with 1 additions and 34 deletions

View File

@ -107,7 +107,6 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
supportingFiles.add(new SupportingFile("swagger_client.gemspec.mustache", "", gemName + ".gemspec"));
supportingFiles.add(new SupportingFile("swagger_client.mustache", libFolder, gemName + ".rb"));
String baseFolder = libFolder + File.separator + gemName;
supportingFiles.add(new SupportingFile("monkey.mustache", baseFolder, "monkey.rb"));
supportingFiles.add(new SupportingFile("swagger.mustache", baseFolder, "swagger.rb"));
String swaggerFolder = baseFolder + File.separator + "swagger";
supportingFiles.add(new SupportingFile("swagger" + File.separator + "request.mustache", swaggerFolder, "request.rb"));

View File

@ -1,31 +0,0 @@
class Hash
unless Hash.method_defined? :stringify_keys
def stringify_keys
inject({}) do |options, (key, value)|
options[key.to_s] = value
options
end
end
end
unless Hash.method_defined? :stringify_keys!
def stringify_keys!
self.replace(self.stringify_keys)
end
end
unless Hash.method_defined? :symbolize_keys
def symbolize_keys
inject({}) do |options, (key, value)|
options[(key.to_sym rescue key) || key] = value
options
end
end
end
unless Hash.method_defined? :symbolize_keys!
def symbolize_keys!
self.replace(self.symbolize_keys)
end
end
end

View File

@ -119,7 +119,7 @@ module {{moduleName}}
def make
request_options = {
:method => self.http_method,
:headers => self.headers.stringify_keys,
:headers => self.headers,
:ssl_verifypeer => Swagger.configuration.verify_ssl,
:cainfo => Swagger.configuration.ssl_ca_cert,
:verbose => Swagger.configuration.debug

View File

@ -1,5 +1,4 @@
# Swagger common files
require '{{gemName}}/monkey'
require '{{gemName}}/swagger'
require '{{gemName}}/swagger/configuration'
require '{{gemName}}/swagger/api_error'