Class: ETL::Processor::RenameProcessor

Inherits:
RowProcessor show all
Defined in:
lib/etl/processor/rename_processor.rb

Overview

Row level processor to rename a field in the row.

Configuration options:

  • :source: the source field name

  • :dest: The destination field name

Instance Method Summary collapse

Methods inherited from RowProcessor

#ensure_columns_available_in_row!, #initialize

Methods inherited from Processor

#initialize

Constructor Details

This class inherits a constructor from ETL::Processor::RowProcessor

Instance Method Details

#process(row) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/etl/processor/rename_processor.rb', line 9

def process(row)
  source_value = row[configuration[:source]]
  case source_value
  when Numeric
    row[configuration[:dest]] = source_value
  when nil
    row[configuration[:dest]] = nil
  else
    row[configuration[:dest]] = source_value.dup
  end
  row.delete(configuration[:source])
  row
end