Class: SmartCsvImport::FailedRowExporter
- Inherits:
-
Object
- Object
- SmartCsvImport::FailedRowExporter
- Defined in:
- lib/smart_csv_import/failed_row_exporter.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(csv_path:, result: nil, import: nil) ⇒ FailedRowExporter
constructor
A new instance of FailedRowExporter.
Constructor Details
#initialize(csv_path:, result: nil, import: nil) ⇒ FailedRowExporter
Returns a new instance of FailedRowExporter.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/smart_csv_import/failed_row_exporter.rb', line 7 def initialize(csv_path:, result: nil, import: nil) raise ArgumentError, "provide either result: or import:" if result.nil? && import.nil? raise ArgumentError, "provide only one of result: or import:" if result && import @csv_path = csv_path @failed_lines = if result errors_by_line_from_result(result) else errors_by_line_from_import(import) end end |
Instance Method Details
#call ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/smart_csv_import/failed_row_exporter.rb', line 19 def call return nil if @failed_lines.empty? original_headers = read_original_headers output_path = generate_output_path write_failed_rows(original_headers, @failed_lines, output_path) output_path end |