Class: Solr::Response::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/solr/response/parser.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_response) ⇒ Parser

Returns a new instance of Parser.



8
9
10
# File 'lib/solr/response/parser.rb', line 8

def initialize(raw_response)
  @raw_response = raw_response
end

Class Method Details

.call(raw_response) ⇒ Object



4
5
6
# File 'lib/solr/response/parser.rb', line 4

def self.call(raw_response)
  new(raw_response).call
end

Instance Method Details

#callObject



12
13
14
15
16
17
18
19
20
# File 'lib/solr/response/parser.rb', line 12

def call
  # 404 is a special case, it didn't hit Solr (more likely than not)
  return not_found_response if @raw_response.status == 404
  parsed_body = @raw_response.body ? JSON.parse(@raw_response.body).freeze : {}
  http_status = parse_http_status
  header = parse_header(parsed_body)
  solr_error = parse_solr_error(parsed_body)
  Solr::Response.new(header: header, http_status: http_status, solr_error: solr_error, body: parsed_body)
end