Permalink
Browse files

extracted secure_instance_url_request

  • Loading branch information...
1 parent 5f19a98 commit 0788d3f13c1cd486160b1589187dc8998bd84268 Diego Scataglini committed Sep 20, 2011
Showing with 5 additions and 3 deletions.
  1. +5 −3 lib/databasedotcom/client.rb
@@ -308,16 +308,18 @@ def http_multipart_post(path, parts, parameters={}, headers={})
private
def within_request(path, opts = {}, parameters={}, headers={})
- req = Net::HTTP.new(URI.parse(self.instance_url).host, 443)
- req.use_ssl = true
encoded_path = prepare_encoded_path_from(path, parameters)
log_request(encoded_path, opts[:data])
- result = yield(req, encoded_path)
+ result = yield(secure_instance_url_request, encoded_path)
log_response(result)
raise SalesForceError.new(result) unless result.is_a?(opts[:expected_result_class] || Net::HTTPSuccess)
result
end
+ def secure_instance_url_request
+ Net::HTTP.new(URI.parse(self.instance_url).host, 443).tap{|n| n.use_ssl = true }
+ end
+
def prepare_encoded_path_from(path, parameters={})
path_parameters = (parameters || {}).collect { |k, v| "#{URI.escape(k.to_s)}=#{URI.escape(v.to_s)}" }.join('&')
[URI.escape(path), path_parameters.empty? ? nil : path_parameters].compact.join('?')

0 comments on commit 0788d3f

Please sign in to comment.