Sha256: 8ba586814c8a8983d6d48404e04a6ffcd0ddae5a56c3b0eeb0c9e07f668d8397

Contents?: true

Size: 517 Bytes

Versions: 2

Compression:

Stored size: 517 Bytes

Contents

# frozen_string_literal: true

module Importeur
  class ETL
    def initialize(extractor:, transformer:, loader:)
      @extractor = extractor
      @transformer = transformer
      @loader = loader
    end

    def call
      extracted = extractor.call
      return if extracted.nil?
      transformed = extracted
        .lazy
        .flat_map(&transformer.method(:call))
        .reject(&:nil?)
      loader.call(transformed.lazy)
    end

    private

    attr_reader :extractor, :transformer, :loader
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
importeur-0.3.0 lib/importeur/etl.rb
importeur-0.2.1 lib/importeur/etl.rb