lib/etl/processor/copy_field_processor.rb in activewarehouse-etl-0.6.1 vs lib/etl/processor/copy_field_processor.rb in activewarehouse-etl-0.7.0
- old
+ new
@@ -1,9 +1,25 @@
-module ETL
- module Processor
- class CopyField < ETL::Processor::RowProcessor
+module ETL #:nodoc:
+ module Processor #:nodoc:
+ # Row processor that will copy one field to another
+ #
+ # Configuration options:
+ # * <tt>:destination</tt>: The destination field
+ # * <tt>:dest</tt>: Alias for :destination
+ # * <tt>:source</tt>: The source field
+ class CopyFieldProcessor < ETL::Processor::RowProcessor
+ # Process the given row
def process(row)
- row[configuration[:destination]] = row[configuration[:source]].dup
+ 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
end
end
end
\ No newline at end of file