class Topographer::Importer::Strategy::Base
Attributes
dry_run[RW]
mapper[RW]
Public Class Methods
new(mapper)
click to toggle source
# File lib/topographer/importer/strategy/base.rb, line 8 def initialize(mapper) @mapper = mapper @dry_run = false end
Public Instance Methods
failure_message()
click to toggle source
# File lib/topographer/importer/strategy/base.rb, line 21 def failure_message 'Unable to import' end
import_record(record_input)
click to toggle source
# File lib/topographer/importer/strategy/base.rb, line 13 def import_record (record_input) raise NotImplementedError end
should_persist_import?(status)
click to toggle source
# File lib/topographer/importer/strategy/base.rb, line 25 def should_persist_import?(status) (@dry_run || status.errors?) ? false : true end
success_message()
click to toggle source
# File lib/topographer/importer/strategy/base.rb, line 17 def success_message 'Imported' end
Private Instance Methods
get_import_status(mapping_result, new_model_errors)
click to toggle source
# File lib/topographer/importer/strategy/base.rb, line 31 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