Module: Decidim::Admin::Import::Readers

Defined in:
decidim-admin/lib/decidim/admin/import/readers.rb,
decidim-admin/lib/decidim/admin/import/readers/csv.rb,
decidim-admin/lib/decidim/admin/import/readers/base.rb,
decidim-admin/lib/decidim/admin/import/readers/json.rb,
decidim-admin/lib/decidim/admin/import/readers/xlsx.rb

Defined Under Namespace

Classes: Base, CSV, JSON, XLSX

Constant Summary collapse

ACCEPTED_MIME_TYPES =

Accepted mime types keys: are used for dynamic help text on admin form. values: are used to validate the file format of imported document.

{
  json: Readers::JSON::MIME_TYPE,
  csv: Readers::CSV::MIME_TYPE,
  xlsx: Readers::XLSX::MIME_TYPE
}.freeze

Class Method Summary collapse

Class Method Details

.allObject


21
22
23
24
25
26
27
# File 'decidim-admin/lib/decidim/admin/import/readers.rb', line 21

def self.all
  [
    Readers::CSV,
    Readers::JSON,
    Readers::XLSX
  ]
end

.search_by_mime_type(mime_type) ⇒ Object


29
30
31
32
33
34
35
# File 'decidim-admin/lib/decidim/admin/import/readers.rb', line 29

def self.search_by_mime_type(mime_type)
  all.each do |reader_klass|
    return reader_klass if mime_type == reader_klass::MIME_TYPE
  end

  nil
end