Method: Endeca::Document.first

Defined in:
lib/endeca/document.rb

.first(query_options = {}) ⇒ Object

Returns the first Document matching the query options.



104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/endeca/document.rb', line 104

def self.first(query_options={})
  response = request(query_options)
  record = if response['AggrRecords'] 
    response['AggrRecords'].first['Records'].first
  elsif response['Records']
    response['Records'].first
  else
    nil
  end

  record && new(record)
end