Class: Antz::Sink::ActiveRecord

Inherits:
Object
  • Object
show all
Defined in:
lib/antz/sink/active_record.rb

Instance Method Summary collapse

Constructor Details

#initialize(model:, on_duplicate: :update) ⇒ ActiveRecord

Returns a new instance of ActiveRecord.



6
7
8
9
# File 'lib/antz/sink/active_record.rb', line 6

def initialize(model:, on_duplicate: :update)
  @model = model
  @on_duplicate = on_duplicate
end

Instance Method Details

#write(records) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/antz/sink/active_record.rb', line 11

def write(records)
  return if records.empty?

  trigger_schema_load
  now = Time.current
  enriched_records = enrich_with_timestamps(records, now)

  persist_records(enriched_records)
end