Method: FlatKit::Jsonl::Writer#write

Defined in:
lib/flat_kit/jsonl/writer.rb

#write(record) ⇒ Object

write the record and return the Position the record was written



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/flat_kit/jsonl/writer.rb', line 14

def write(record)
  case record
  when FlatKit::Jsonl::Record
    write_record(record)
  when FlatKit::Record
    converted_record = ::FlatKit::Jsonl::Record.from_record(record)
    write_record(converted_record)
  else
    raise FlatKit::Error, "Unable to write records of type #{record.class}"
  end
rescue FlatKit::Error => e
  raise e
rescue StandardError => e
  ::FlatKit.logger.error "Error writing jsonl records to #{output.name}: #{e}"
  raise ::FlatKit::Error, e
end