Class: Reference::Loader
- Inherits:
-
Object
- Object
- Reference::Loader
- Includes:
- Mixins::Logging
- Defined in:
- lib/reference/loader.rb
Overview
Public: This class handles the import of data located in the ‘data/reference/’ folder.
We seed the database with default values for reference data.
Instance Method Summary collapse
-
#initialize ⇒ Loader
constructor
Internal: Creates our instance of Reader, that handles the actual import.
-
#perform_import ⇒ Object
Public: The primary interface to this class.
Constructor Details
#initialize ⇒ Loader
Internal: Creates our instance of Reader, that handles the actual import.
11 12 13 |
# File 'lib/reference/loader.rb', line 11 def initialize @reader = Interchange::Reader.new end |
Instance Method Details
#perform_import ⇒ Object
Public: The primary interface to this class. We setup to load all reference data in the data/reference/ folder, such that we leave the seed files intact, do not destroy existing data prior, and that we just replace any imports for data that already exists based on each model’s determination of uniqueness.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/reference/loader.rb', line 20 def perform_import log "#{self.class.name} perform_import(): Began import process." # Set the parameters guiding how the import should be run: cleanup = false duplicate_strategy = Enums::DuplicateStrategy::REPLACE # Wrap the import process in a block that can log the overall status: @reader.mark_import_operation do # Kick off the underlying import operation on the model(s) requested: root_model_classes.each do |model_class| puts "Reference::Loader - Loading reference data (if any) for model: #{model_class.to_s}" @reader.import model_class, cleanup, duplicate_strategy, Reference::BASE_PATH end end end |