class LHC::Response
and provides functionality to access response data.
The response contains the raw response (typhoeus)
def [](key)
def [](key) data[key] end
def body
def body body_replacement || raw.body.presence end
def data
def data @data ||= body.present? ? LHC::Response::Data.new(self) : nil end
def format
def format return LHC::Formats::JSON.new if request.nil? request.format end
def initialize(raw, request, from_cache: false)
A response is initalized with the underlying raw response (typhoeus in our case)
def initialize(raw, request, from_cache: false) self.request = request self.raw = raw @from_cache = from_cache end
def time
def time time_ms * 1000 end
def time_ms
def time_ms raw.time || 0 end
def timeout?
def timeout? raw.timed_out? end