Class: Ductr::SQLite::BasicLookup
- Inherits:
-
ETL::Transform
- Object
- ETL::Transform
- Ductr::SQLite::BasicLookup
- Defined in:
- lib/ductr/sqlite/basic_lookup.rb
Overview
A lookup control that execute one query per row, registered as :basic
.
The job's method must return a row which will merged with the current row:
lookup :some_sqlite_database, :basic def my_lookup(db, row) db[:items_bis].where(item: row[:id]).limit(1) end
As the control merge the looked up row with the current row, ensure that column names are different or they will be overwritten.
If the lookup returns a falsy value, nothing won't be merged with the current row.
Instance Method Summary collapse
-
#process(row) ⇒ Hash<Symbol, Object>
Calls the job's method to merge its result with the current row.
Instance Method Details
#process(row) ⇒ Hash<Symbol, Object>
Calls the job's method to merge its result with the current row.
29 30 31 32 33 34 |
# File 'lib/ductr/sqlite/basic_lookup.rb', line 29 def process(row) matching_row = call_method(adapter.db, row).first return row unless matching_row row.merge matching_row end |