Sha256: 608eca72ccaf40164eb1adceada53b2504d53663f75776cfe4998b5673dd6619

Contents?: true

Size: 650 Bytes

Versions: 2

Compression:

Stored size: 650 Bytes

Contents

# frozen_string_literal: true

module Ductr
  module Sequel
    #
    # A lookup control that execute one query per row.
    #
    class BasicLookup < Ductr::ETL::Transform
      #
      # Calls the job's method to merge its result with the current row.
      #
      # @param [Hash<Symbol, Object>] row The current row, preferably a Hash
      #
      # @return [Hash<Symbol, Object>] The row merged with looked up row or the untouched row if nothing was found
      #
      def process(row)
        matching_row = call_method(adapter.db, row).first
        return row unless matching_row

        row.merge matching_row
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ductr-0.2.1 lib/ductr/sequel/basic_lookup.rb
ductr-0.2.0 lib/ductr/sequel/basic_lookup.rb