class Solr::Response

Constants

OK

Attributes

body[R]
header[R]
http_status[R]
solr_error[R]

Public Class Methods

new(header:, http_status: HttpStatus.ok, solr_error: SolrError.none, body: {}) click to toggle source
# File lib/solr/response.rb, line 12
def initialize(header:, http_status: HttpStatus.ok, solr_error: SolrError.none, body: {})
  @header = header
  @http_status = http_status
  @solr_error = solr_error
  @body = body
  freeze
end

Public Instance Methods

error?() click to toggle source
# File lib/solr/response.rb, line 24
def error?
  !ok?
end
error_message() click to toggle source
# File lib/solr/response.rb, line 36
def error_message
  return if ok?
  solr_error ? solr_error.message : http_status.inspect
end
inspect() click to toggle source
# File lib/solr/response.rb, line 41
def inspect
  return OK if ok?
  str = "Error: #{http_status.inspect}"
  str << "\n#{solr_error.inspect}" if solr_error
  str
end
ok?() click to toggle source
# File lib/solr/response.rb, line 20
def ok?
  header.ok?
end
status() click to toggle source
# File lib/solr/response.rb, line 28
def status
  if header.status.zero?
    OK
  else
    header.status
  end
end