class LHC::Caching

def to_cache(response)

converts a LHC::Response object to json, we store in the cache
def to_cache(response)
  data = {}
  data[:body] = response.body
  data[:code] = response.code
  # convert into a actual hash because the typhoeus headers object breaks marshaling
  data[:headers] = response.headers ? Hash[response.headers] : response.headers
  # return_code is quite important as Typhoeus relies on it in order to determin 'success?'
  data[:return_code] = response.options[:return_code]
  # in a test scenario typhoeus uses mocks and not return_code to determine 'success?'
  data[:mock] = response.mock
  data
end