Class: Smuggle::Services::Import
- Inherits:
-
Object
- Object
- Smuggle::Services::Import
- Defined in:
- lib/smuggle/services/import.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call(model:, filepath:, **options) ⇒ Object
-
#initialize(resolver: Smuggle::Importer::Resolver.new) ⇒ Import
constructor
A new instance of Import.
Constructor Details
Class Method Details
.call(**args) ⇒ Object
6 7 8 |
# File 'lib/smuggle/services/import.rb', line 6 def self.call(**args) new.call(args) end |
Instance Method Details
#call(model:, filepath:, **options) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/smuggle/services/import.rb', line 14 def call(model:, filepath:, **) importer = .fetch(:importer) { @resolver.call(model: model) } CSV.read(filepath, headers: true, **importer.csv_converters).map do |row| importer.new(row, model).persist end end |