Class: Topographer::Importer::Strategy::ImportNewRecord

Inherits:
Base
  • Object
show all
Defined in:
lib/topographer/importer/strategy/import_new_record.rb

Instance Attribute Summary

Attributes inherited from Base

#dry_run, #mapper

Instance Method Summary collapse

Methods inherited from Base

#failure_message, #initialize, #should_persist_import?, #success_message

Constructor Details

This class inherits a constructor from Topographer::Importer::Strategy::Base

Instance Method Details

#import_record(source_data) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/topographer/importer/strategy/import_new_record.rb', line 3

def import_record (source_data)
  mapping_result = mapper.map_input(source_data)
  new_model = mapper.model_class.new(mapping_result.data)
  new_model.valid?
  model_errors = new_model.errors.full_messages
  status = get_import_status(mapping_result, model_errors)

  new_model.save if should_persist_import?(status)

  status
end