Class: RestClient::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/lucid_works/patch_restclient.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#process_get_params(url, headers) ⇒ Object

Extract the query parameters for get request and append them to the url



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/lucid_works/patch_restclient.rb', line 21

def process_get_params url, headers
  # LucidWorks: we also need params on a :delete
  if [:get, :head, :delete].include? method
  # if [:get, :head].include? method
    get_params = {}
    headers.delete_if do |key, value|
      if 'params' == key.to_s.downcase && value.is_a?(Hash)
        get_params.merge! value
        true
      else
        false
      end
    end
    unless get_params.empty?
      query_string = get_params.collect { |k, v| "#{k.to_s}=#{CGI::escape(v.to_s)}" }.join('&')
      url + "?#{query_string}"
    else
      url
    end
  else
    url
  end
end