Class: NcsNavigator::Warehouse::Transformers::MdesCsv::MultipleTableReader

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/ncs_navigator/warehouse/transformers/mdes_csv/multiple_table_reader.rb

Overview

An enumerable that joins the results for several TableReaders into a single #each call.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(configuration, table_readers) ⇒ MultipleTableReader

Returns a new instance of MultipleTableReader.

Parameters:



15
16
17
18
# File 'lib/ncs_navigator/warehouse/transformers/mdes_csv/multiple_table_reader.rb', line 15

def initialize(configuration, table_readers)
  @configuration = configuration
  @table_readers = table_readers.sort_by { |r| configuration.models_module.mdes_order.index(r.model) }
end

Instance Attribute Details

#configurationObject (readonly)

Returns the value of attribute configuration.



10
11
12
# File 'lib/ncs_navigator/warehouse/transformers/mdes_csv/multiple_table_reader.rb', line 10

def configuration
  @configuration
end

#table_readersObject (readonly)

Returns the value of attribute table_readers.



10
11
12
# File 'lib/ncs_navigator/warehouse/transformers/mdes_csv/multiple_table_reader.rb', line 10

def table_readers
  @table_readers
end

Instance Method Details

#eachObject



20
21
22
23
24
25
26
# File 'lib/ncs_navigator/warehouse/transformers/mdes_csv/multiple_table_reader.rb', line 20

def each
  table_readers.each do |reader|
    reader.each do |record|
      yield record
    end
  end
end

#nameObject



28
29
30
# File 'lib/ncs_navigator/warehouse/transformers/mdes_csv/multiple_table_reader.rb', line 28

def name
  table_readers.collect(&:name).join(', ')
end