Class: Solr::Response
- Inherits:
-
Object
- Object
- Solr::Response
- Defined in:
- lib/solr/response.rb,
lib/solr/response/header.rb,
lib/solr/response/parser.rb,
lib/solr/response/solr_error.rb,
lib/solr/response/http_status.rb
Defined Under Namespace
Classes: Header, HttpStatus, Parser, SolrError
Constant Summary collapse
- OK =
'OK'.freeze
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#header ⇒ Object
readonly
Returns the value of attribute header.
-
#http_status ⇒ Object
readonly
Returns the value of attribute http_status.
-
#solr_error ⇒ Object
readonly
Returns the value of attribute solr_error.
Instance Method Summary collapse
- #error? ⇒ Boolean
- #error_message ⇒ Object
-
#initialize(header:, http_status: HttpStatus.ok, solr_error: SolrError.none, body: {}) ⇒ Response
constructor
A new instance of Response.
- #inspect ⇒ Object
- #ok? ⇒ Boolean
- #status ⇒ Object
Constructor Details
#initialize(header:, http_status: HttpStatus.ok, solr_error: SolrError.none, body: {}) ⇒ Response
Returns a new instance of Response.
12 13 14 15 16 17 18 |
# 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 |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
10 11 12 |
# File 'lib/solr/response.rb', line 10 def body @body end |
#header ⇒ Object (readonly)
Returns the value of attribute header.
10 11 12 |
# File 'lib/solr/response.rb', line 10 def header @header end |
#http_status ⇒ Object (readonly)
Returns the value of attribute http_status.
10 11 12 |
# File 'lib/solr/response.rb', line 10 def http_status @http_status end |
#solr_error ⇒ Object (readonly)
Returns the value of attribute solr_error.
10 11 12 |
# File 'lib/solr/response.rb', line 10 def solr_error @solr_error end |
Instance Method Details
#error? ⇒ Boolean
24 25 26 |
# File 'lib/solr/response.rb', line 24 def error? !ok? end |
#error_message ⇒ Object
36 37 38 39 |
# File 'lib/solr/response.rb', line 36 def return if ok? solr_error ? solr_error. : http_status.inspect end |
#inspect ⇒ Object
41 42 43 44 45 46 |
# 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? ⇒ Boolean
20 21 22 |
# File 'lib/solr/response.rb', line 20 def ok? header.ok? end |
#status ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/solr/response.rb', line 28 def status if header.status.zero? OK else header.status end end |