Class: SolidusImporter::ProcessRow
- Inherits:
-
Object
- Object
- SolidusImporter::ProcessRow
- Defined in:
- lib/solidus_importer/process_row.rb
Overview
This class process a single row of an import running the configured processor in chain.
Instance Method Summary collapse
-
#initialize(importer, row) ⇒ ProcessRow
constructor
A new instance of ProcessRow.
- #process(initial_context) ⇒ Object
Constructor Details
#initialize(importer, row) ⇒ ProcessRow
Returns a new instance of ProcessRow.
8 9 10 11 12 |
# File 'lib/solidus_importer/process_row.rb', line 8 def initialize(importer, row) @importer = importer @row = row validate! end |
Instance Method Details
#process(initial_context) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/solidus_importer/process_row.rb', line 14 def process(initial_context) context = initial_context.dup.merge!(row_id: @row.id, importer: @importer, data: @row.data) @importer.processors.each do |processor| begin processor.call(context) rescue StandardError => e context.merge!(success: false, messages: e.) # rubocop:disable Performance/RedundantMerge break end end @importer.handle_row_import(context) @row.update!( state: context[:success] ? :completed : :failed, messages: context[:messages] ) check_import_finished(context) context end |