Module: InstDataShipper::DataSources::Base

Included in:
CanvasReports, LocalTables
Defined in:
lib/inst_data_shipper/data_sources/base.rb

Defined Under Namespace

Modules: Concern, ModuleHelperMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object

This could be a Concern, but we don’t want Concern inheritance logic kicking in if it is included into another Concern.



6
7
8
9
10
# File 'lib/inst_data_shipper/data_sources/base.rb', line 6

def self.included(base)
  base.extend ActiveSupport::Concern unless self.is_a?(Class) || base < ActiveSupport::Concern
  base.extend ModuleHelperMethods
  base.send(:include, Concern)
end

Instance Method Details

#process_raw_data_enumerator(table_def, enumerator, dest) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/inst_data_shipper/data_sources/base.rb', line 12

def process_raw_data_enumerator(table_def, enumerator, dest)
  enumerator.each_slice(1000) do |batch|
    Array(table_def[:batch_preprocess]).each do |preprocess|
      batch = instance_exec(batch, &preprocess).compact
    end

    batch.each do |m|
      Array(table_def[:row_preprocess]).each do |preprocess|
        m = instance_exec(m, &preprocess)
        next if m.nil?
      end

      dest << table_def[:columns].map do |c|
        instance_exec(m, &c[:block])
      end
    end
  end
end