Class: Decidim::Admin::Import::Readers::Base

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

Overview

Abstract class with a very naive default implementation. Each importable file type should have it’s own reader.

Direct Known Subclasses

CSV, JSON, XLS

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ Base

Returns a new instance of Base.



10
11
12
# File 'lib/decidim/admin/import/readers/base.rb', line 10

def initialize(file)
  @file = file
end

Instance Method Details

#read_rowsObject

The read_rows method should iterate over each row of the data and yield the data array of each row with the row’s index. The first row yielded with index 0 needs to contain the data headers which can be later used to map the data to correct attributes.

This needs to be implemented by the extending classes.

Raises:

  • (NotImplementedError)


20
21
22
# File 'lib/decidim/admin/import/readers/base.rb', line 20

def read_rows
  raise NotImplementedError
end