Class: CSVStepImporter::Model::ImportableModel

Inherits:
Model show all
Defined in:
lib/csv_step_importer/model/importable_model.rb

Instance Attribute Summary

Attributes inherited from Model

#dao_values

Attributes inherited from Node

#children, #env, #parent

Instance Method Summary collapse

Methods inherited from Model

#add_daos, #build_daos_for_row, cache_key, #columns, #dao_class, #dao_node, #daos, #initialize, #link_rows_to_daos

Methods inherited from Node

#add_children, #create_or_update, #initialize, #run_validations!, #validate_children

Methods inherited from Base

#assign_attributes, #create_or_update, #inspect, #persisted?, #save, #save!, #to_s, #update

Constructor Details

This class inherits a constructor from CSVStepImporter::Model::Model

Instance Method Details

#add_model_childrenObject

Logic



55
56
57
# File 'lib/csv_step_importer/model/importable_model.rb', line 55

def add_model_children
  add_children [dao_node, importer_class, reflector_class], prepend: true
end

#finder_keysObject

NOTE: required only when reflector class is set example: [:email]



34
35
36
# File 'lib/csv_step_importer/model/importable_model.rb', line 34

def finder_keys
  raise "please extend and implement"
end

#finder_scopeObject

NOTE: required only when reflector class is set example: env.company_users



28
29
30
# File 'lib/csv_step_importer/model/importable_model.rb', line 28

def finder_scope
  model_class.all
end

#importer_classObject

set to nil in order to deactivate



16
17
18
# File 'lib/csv_step_importer/model/importable_model.rb', line 16

def importer_class
  CSVStepImporter::Model::Importer
end

#model_classObject

example: User



11
12
13
# File 'lib/csv_step_importer/model/importable_model.rb', line 11

def model_class
  raise "please extend and implement"
end

#on_duplicate_key_ignoreObject

NOTE: required only when importer class is set see: github.com/zdennis/activerecord-import/wiki/On-Duplicate-Key-Update



40
41
42
# File 'lib/csv_step_importer/model/importable_model.rb', line 40

def on_duplicate_key_ignore
  false
end

#on_duplicate_key_updateObject

NOTE: required only when importer class is set example [:email, :updated_at] see: github.com/zdennis/activerecord-import/wiki/On-Duplicate-Key-Update



47
48
49
# File 'lib/csv_step_importer/model/importable_model.rb', line 47

def on_duplicate_key_update
  raise "please extend and implement"
end

#reflector_classObject

return CSVStepImporter::Model::Reflector in order to enable reflections (e.g. get ids of all rows) disabled by default



22
23
24
# File 'lib/csv_step_importer/model/importable_model.rb', line 22

def reflector_class
  nil
end