Class: ETL::Transform::DefaultTransform

Inherits:
Transform show all
Defined in:
lib/etl/transform/default_transform.rb

Overview

Transform which will replace nil or empty values with a specified value.

Instance Attribute Summary (collapse)

Attributes inherited from Transform

#configuration, #control, #name

Instance Method Summary (collapse)

Methods inherited from Transform

benchmarks, transform

Constructor Details

- (DefaultTransform) initialize(control, name, configuration)

Initialize the transform

Configuration options:

  • :default_value: The default value to use if the incoming value is blank



10
11
12
13
# File 'lib/etl/transform/default_transform.rb', line 10

def initialize(control, name, configuration)
  super
  @default_value = configuration[:default_value]
end

Instance Attribute Details

- (Object) default_value

Returns the value of attribute default_value



5
6
7
# File 'lib/etl/transform/default_transform.rb', line 5

def default_value
  @default_value
end

Instance Method Details

- (Object) transform(name, value, row)

Transform the value



15
16
17
# File 'lib/etl/transform/default_transform.rb', line 15

def transform(name, value, row)
  value.blank? ? default_value : value
end