module HTTPWrapper::Util

Public Class Methods

hash_to_query(hash) click to toggle source
# File lib/http_wrapper/util.rb, line 16
def self.hash_to_query(hash)
  URI.encode_www_form hash
end
query_to_hash(query) click to toggle source
# File lib/http_wrapper/util.rb, line 12
def self.query_to_hash(query)
  Hash[URI.decode_www_form query]
end
validate_hash_keys(hash_to_check, known_keys_array) click to toggle source
# File lib/http_wrapper/util.rb, line 5
def self.validate_hash_keys(hash_to_check, known_keys_array)
  unknown_keys = hash_to_check.keys - known_keys_array
  return if unknown_keys.empty?

  raise UnknownKeyError, "Unknown keys: #{unknown_keys.join(', ')}"
end