Class: Chewy::Index::Import::JournalBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/chewy/index/import/journal_builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(index, to_index: [], delete: []) ⇒ JournalBuilder

Returns a new instance of JournalBuilder.



5
6
7
8
9
# File 'lib/chewy/index/import/journal_builder.rb', line 5

def initialize(index, to_index: [], delete: [])
  @index = index
  @to_index = to_index
  @delete = delete
end

Instance Method Details

#bulk_bodyObject



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/chewy/index/import/journal_builder.rb', line 11

def bulk_body
  Chewy::Index::Import::BulkBuilder.new(
    Chewy::Stash::Journal,
    to_index: [
      entries(:index, @to_index),
      entries(:delete, @delete)
    ].compact
  ).bulk_body.each do |item|
    item.values.first.merge!(
      _index: Chewy::Stash::Journal.index_name
    )
  end
end