Class: CSVStepImporter::Model::Importer

Inherits:
Node
  • Object
show all
Defined in:
lib/csv_step_importer/model/importer.rb

Instance Attribute Summary collapse

Attributes inherited from Node

#children, #env, #parent

Instance Method Summary collapse

Methods inherited from Node

#add_children, #build_env, #initialize, #run_validations!, #validate_children

Methods inherited from Base

#ancestors, #assign_attributes, #inspect, #persisted?, #save, #save!, set, #to_s, #update

Constructor Details

This class inherits a constructor from CSVStepImporter::Node

Instance Attribute Details

#dao_valuesObject

Returns the value of attribute dao_values.



8
9
10
# File 'lib/csv_step_importer/model/importer.rb', line 8

def dao_values
  @dao_values
end

Instance Method Details

#create_or_updateObject



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/csv_step_importer/model/importer.rb', line 16

def create_or_update
  model_class.import(
    columns,
    dao_values,
    on_duplicate_key_ignore: on_duplicate_key_ignore,
    on_duplicate_key_update: on_duplicate_key_update,
    validate: false,
    timestamps: false,
  )

  true
end

#import(values) ⇒ Object



29
30
31
32
# File 'lib/csv_step_importer/model/importer.rb', line 29

def import(values)
  self.values = values
  save!
end