Class: Ductr::SequelBase::MatchLookup

Inherits:
ETL::BufferedTransform show all
Defined in:
lib/ductr/sequel_base/match_lookup.rb

Overview

A lookup control that execute the query for a bunch of rows and merge them with the buffer’s rows.

Instance Attribute Summary

Attributes inherited from ETL::BufferedTransform

#buffer

Attributes inherited from ETL::Control

#adapter, #job_method, #options

Instance Method Summary collapse

Methods inherited from ETL::BufferedTransform

#buffer_size, #close, #flush_buffer, #process

Methods inherited from ETL::Transform

#close, #process

Methods inherited from ETL::Control

#call_method, #initialize

Constructor Details

This class inherits a constructor from Ductr::ETL::Control

Instance Method Details

#from_keySymbol

The looked up row key to match.

Returns:

  • (Symbol)

    The column name



14
15
16
# File 'lib/ductr/sequel_base/match_lookup.rb', line 14

def from_key
  @options[:merge].first
end

#on_flush {|row| ... } ⇒ void

This method returns an undefined value.

Opens the database if needed, calls the job’s method and merges the looked up rows with corresponding buffer rows.

Yields:

  • (row)

    The each block

Yield Parameters:

  • row (Hash<Symbol, Object>)

    The merged row



36
37
38
39
40
41
42
43
# File 'lib/ductr/sequel_base/match_lookup.rb', line 36

def on_flush(&)
  call_method(adapter.db, buffer_keys).each do |row|
    match = buffer_find(row)
    next yield(row) unless match

    yield(row.merge match)
  end
end

#to_keySymbol

The buffer row key to match.

Returns:

  • (Symbol)

    The column name



23
24
25
# File 'lib/ductr/sequel_base/match_lookup.rb', line 23

def to_key
  @options[:merge].last
end