Class: Chewy::Type::Import::JournalBuilder

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

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of JournalBuilder.



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

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

Instance Method Details

#bulk_bodyObject



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

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