Class: ActiveRecordCSVImporter::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/activerecord_csv_importer/runner.rb

Overview

Do the actual import.

It iterates over the rows’ models and persist them. It returns a ‘Report`.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.call(*args) ⇒ Object



6
7
8
# File 'lib/activerecord_csv_importer/runner.rb', line 6

def self.call(*args)
  new(*args).call
end

Instance Method Details

#callObject

Persist the csv rows and return a Report



20
21
22
23
24
25
26
27
# File 'lib/activerecord_csv_importer/runner.rb', line 20

def call
  report.total_count = rows.count
  report.in_progress!
  persist_rows!
  report.done!

  report
end