Module: Restfully::HTTP::Helper
Instance Method Summary collapse
Instance Method Details
#sanitize_head(h = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/restfully/http/helper.rb', line 5 def sanitize_head(h = {}) sanitized_headers = {} h.each do |key, value| sanitized_key = key.to_s. downcase. gsub(/[_-]/, ' '). split(' '). map{|word| word.capitalize}. join("-") sanitized_value = case value when Array value.join(", ") else value end sanitized_headers[sanitized_key] = sanitized_value end sanitized_headers end |
#sanitize_query(h = {}) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/restfully/http/helper.rb', line 25 def sanitize_query(h = {}) sanitized_query = {} h.each do |key,value| sanitized_query[key] = stringify(value) end sanitized_query end |