class SolrMakr::SolrAPI::Response
Attributes
raw_response[R]
@!attribute [r] raw_response
@return [ActiveSupport::HashWithIndifferentAccess]
Public Class Methods
new(raw_response = {})
click to toggle source
@param [Hash] raw_response
# File lib/solr_makr/solr_api/response.rb, line 5 def initialize(raw_response = {}) @raw_response = raw_response.with_indifferent_access end
Public Instance Methods
array(*keys)
click to toggle source
@param [<String, Symbol>] keys path to the desired array @return [Array]
# File lib/solr_makr/solr_api/response.rb, line 17 def array(*keys) Array(dig(*keys)) end
dig(*keys)
click to toggle source
Dig into the response data by a given path.
@param [<String, Symbol>] keys path to the desired value @return [Object] if non-hashlike @return [ActiveSupport::HashWithIndifferentAccess] if hash-like
# 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
Also aliased as: []
success?()
click to toggle source
# File lib/solr_makr/solr_api/response.rb, line 56 def success? status == 0 end
to_s()
click to toggle source
# File lib/solr_makr/solr_api/response.rb, line 64 def to_s "#<#{self.class.name} #{JSON.pretty_generate(raw_response)}>" end