Class: ETL::Processor::CopyFieldProcessor

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

Overview

Row processor that will copy one field to another

Configuration options:

  • :destination: The destination field

  • :dest: Alias for :destination

  • :source: The source field

Instance Method Summary collapse

Methods inherited from RowProcessor

#initialize

Methods inherited from Processor

#initialize

Constructor Details

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

Instance Method Details

#process(row) ⇒ Object

Process the given row



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/etl/processor/copy_field_processor.rb', line 11

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