Class: CloudSearch::Indexer

Inherits:
Object
  • Object
show all
Includes:
ConfigurationChecking
Defined in:
lib/cloud_search/indexer.rb

Instance Method Summary collapse

Constructor Details

#initializeIndexer

Returns a new instance of Indexer.



5
6
7
# File 'lib/cloud_search/indexer.rb', line 5

def initialize
  @documents = []
end

Instance Method Details

#<<(document) ⇒ Object Also known as: add

Raises:



9
10
11
12
# File 'lib/cloud_search/indexer.rb', line 9

def <<(document)
  raise InvalidDocument.new(document) unless document.valid?
  @documents << document
end

#documentsObject



16
17
18
# File 'lib/cloud_search/indexer.rb', line 16

def documents
  @documents.freeze
end

#indexObject



20
21
22
23
24
25
26
# File 'lib/cloud_search/indexer.rb', line 20

def index
  cloud_search_response = RestClient.post url, documents_json, headers
  message               = "#{cloud_search_response.code} - #{cloud_search_response.length} bytes\n#{url}\n"
  response              = JSON.parse cloud_search_response.body

  [response, message]
end