Class: Decidim::Admin::Import::ImporterFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/decidim/admin/import/importer_factory.rb

Overview

A factory class providing easier way to create new importers.

Class Method Summary collapse

Class Method Details

.build(file, mime_type) ⇒ Object

Raises:

  • (NotImplementedError)


8
9
10
11
12
13
# File 'lib/decidim/admin/import/importer_factory.rb', line 8

def self.build(file, mime_type, **)
  reader = Readers.search_by_mime_type(mime_type)
  raise NotImplementedError, "No reader implemented for mime type: #{mime_type}" if reader.nil?

  Importer.new(file:, reader:, **)
end