Class: SolrMakr::SolrAPI::Response
- Inherits:
-
Object
- Object
- SolrMakr::SolrAPI::Response
show all
- Defined in:
- lib/solr_makr/solr_api/response.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(raw_response = {}) ⇒ Response
Returns a new instance of Response.
5
6
7
|
# File 'lib/solr_makr/solr_api/response.rb', line 5
def initialize(raw_response = {})
@raw_response = raw_response.with_indifferent_access
end
|
Instance Attribute Details
#failure ⇒ String
42
43
44
45
46
|
# File 'lib/solr_makr/solr_api/response.rb', line 42
attr_lazy_reader :failure do
unless success?
exception.fetch(:msg) or error.fetch(:msg) or 'unknown failure'
end
end
|
#raw_response ⇒ ActiveSupport::HashWithIndifferentAccess
11
12
13
|
# File 'lib/solr_makr/solr_api/response.rb', line 11
def raw_response
@raw_response
end
|
36
37
38
|
# File 'lib/solr_makr/solr_api/response.rb', line 36
attr_lazy_reader :response_header do
dig :responseHeader
end
|
Instance Method Details
#array(*keys) ⇒ Array
17
18
19
|
# File 'lib/solr_makr/solr_api/response.rb', line 17
def array(*keys)
Array(dig(*keys))
end
|
#dig(*keys) ⇒ Object, ActiveSupport::HashWithIndifferentAccess
Also known as:
[]
Dig into the response data by a given path.
26
27
28
29
30
|
# File 'lib/solr_makr/solr_api/response.rb', line 26
def dig(*keys)
keys.reduce raw_response do |hsh, key|
hsh[key] if hsh.respond_to?(:[])
end
end
|
#success? ⇒ Boolean
56
57
58
|
# File 'lib/solr_makr/solr_api/response.rb', line 56
def success?
status == 0
end
|
#to_s ⇒ Object
64
65
66
|
# File 'lib/solr_makr/solr_api/response.rb', line 64
def to_s
"#<#{self.class.name} #{JSON.pretty_generate(raw_response)}>"
end
|