Class: Dionysus::Producer::EmbeddedTimestampRepair

Inherits:
Object
  • Object
show all
Defined in:
lib/dionysus/producer/embedded_timestamp_repair.rb

Constant Summary collapse

TIMESTAMP_ATTRIBUTE =
"updated_at"
PRIMARY_KEY_ATTRIBUTE =
"id"
ISO8601_WITH_OFFSET =
%r{\A\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:?\d{2})\z}

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(records, config) ⇒ EmbeddedTimestampRepair

Returns a new instance of EmbeddedTimestampRepair.



16
17
18
19
# File 'lib/dionysus/producer/embedded_timestamp_repair.rb', line 16

def initialize(records, config)
  @records = records
  @config = config
end

Class Method Details

.call(records, config) ⇒ Object

Takes the block that serializes, so a repaired record can be serialized again in one place.



9
10
11
# File 'lib/dionysus/producer/embedded_timestamp_repair.rb', line 9

def self.call(records, config, &)
  new(records, config).call(&)
end

Instance Method Details

#callObject



21
22
23
24
25
26
27
28
# File 'lib/dionysus/producer/embedded_timestamp_repair.rb', line 21

def call
  payload, read_at = yield
  return [payload, read_at] unless config.touch_records_behind_their_embedded_records
  return [payload, read_at] unless payload.is_a?(Array)
  return [payload, read_at] unless any_repaired?(payload)

  yield
end