Sha256: 3435463428f3a2bc4c2a102e2b3b65a52ff07885ba3bbd605085c05ae7f27b61
Contents?: true
Size: 1.09 KB
Versions: 2
Compression:
Stored size: 1.09 KB
Contents
module Topographer class Importer module Strategy class Base attr_accessor :dry_run, :mapper def initialize(mapper) @mapper = mapper @dry_run = false end def import_record (record_input) raise NotImplementedError end def success_message 'Imported' end def failure_message 'Unable to import' end def should_persist_import?(status) (@dry_run || status.errors?) ? false : true end private def get_import_status(mapping_result, new_model_errors) status = Topographer::Importer::Strategy::ImportStatus.new(mapping_result.source_identifier) mapping_result.errors.values.each do |error| status.add_error(:mapping, error) end new_model_errors.each do |error| status.add_error(:validation, error) end status.message = (status.errors?) ? failure_message : success_message status.set_timestamp status end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
topographer-0.0.9 | lib/topographer/importer/strategy/base.rb |
topographer-0.0.8 | lib/topographer/importer/strategy/base.rb |