Class: Bulkrax::CsvTemplate::ModelLoader

Inherits:
Object
  • Object
show all
Defined in:
app/services/bulkrax/csv_template/model_loader.rb

Overview

Handles model loading based on configuration

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(models) ⇒ ModelLoader

Returns a new instance of ModelLoader.



9
10
11
# File 'app/services/bulkrax/csv_template/model_loader.rb', line 9

def initialize(models)
  @models = load_models(models)
end

Instance Attribute Details

#modelsObject (readonly)

Returns the value of attribute models.



7
8
9
# File 'app/services/bulkrax/csv_template/model_loader.rb', line 7

def models
  @models
end

Class Method Details

.determine_klass_for(model_name) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'app/services/bulkrax/csv_template/model_loader.rb', line 13

def self.determine_klass_for(model_name)
  if Bulkrax.config.object_factory == Bulkrax::ValkyrieObjectFactory
    Valkyrie.config.resource_class_resolver.call(model_name)
  else
    model_name.constantize
  end
rescue StandardError
  nil
end