Class: Lite::Report::Record

Inherits:
Base
  • Object
show all
Defined in:
lib/lite/report/record.rb

Instance Method Summary collapse

Methods inherited from Base

export, import, #initialize

Constructor Details

This class inherits a constructor from Lite::Report::Base

Instance Method Details

#exportObject



7
8
9
10
# File 'lib/lite/report/record.rb', line 7

def export
  assign_headers_to_csv_options!
  generate_or_stream_export!
end

#importObject



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/lite/report/record.rb', line 12

def import
  assert_klass_data_option!
  assign_import_csv_options!

  @data = Lite::Report::Hash.import(@data, csv_options: @csv_options, data_options: @data_options)
                            .each do |row|
                              row.delete(:id) || row.delete('id')
                              (row['created_at'] ||= timestamp) if created_at_timestamp?
                              (row['updated_at'] ||= timestamp) if updated_at_timestamp?
                            end

  klass.insert_all(@data, **@import_options)
end