class Acter::Response

Attributes

body[R]
body_is_json[R]
body_is_json?[R]
headers[R]
status[R]
success[R]
success?[R]

Public Class Methods

new(status, headers, body) click to toggle source
# File lib/acter/response.rb, line 5
def initialize(status, headers, body)
  @status = status
  @success = (200..299).include?(status[/\d+/].to_i)
  @headers = headers.sort.map {|a| a.join(": ") }
  @body = case body
    when String
      @body_is_json = false
      body
    else
      @body_is_json = true
      MultiJson.dump(body, pretty: true)
    end
end
new_from_faraday(faraday_response) click to toggle source
# File lib/acter/response.rb, line 19
def self.new_from_faraday(faraday_response)
  status_string = "#{faraday_response.status} #{faraday_response.reason_phrase}"
  new(status_string, faraday_response.headers, faraday_response.body)
end