Class: Crefo::Service::Search::Response

Inherits:
Response
  • Object
show all
Defined in:
lib/crefo/service/search/response.rb

Instance Attribute Summary

Attributes inherited from Response

#attachments, #body, #document_hash

Instance Method Summary collapse

Methods inherited from Response

#document_body_hash, #document_fault_hash, #document_reponse_hash, #initialize, #response_id, response_name, response_name=

Constructor Details

This class inherits a constructor from Crefo::Service::Response

Instance Method Details

#hitsObject

ensure that the result is always a array



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/crefo/service/search/response.rb', line 12

def hits
  @hits ||= begin
    object = document_body_hash[:hit]
    if object.nil?
      []
    elsif object.respond_to?(:to_ary)
      object.to_ary || [object]
    else
      [object]
    end
  end
end

#resultObject



7
8
9
# File 'lib/crefo/service/search/response.rb', line 7

def result
  hits
end