Class: ETL::Transform::DefaultTransform
- 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
-
#default_value ⇒ Object
Returns the value of attribute default_value.
Attributes inherited from Transform
#configuration, #control, #name
Instance Method Summary collapse
-
#initialize(control, name, configuration) ⇒ DefaultTransform
constructor
Initialize the transform.
-
#transform(name, value, row) ⇒ Object
Transform the value.
Methods inherited from Transform
Constructor Details
#initialize(control, name, configuration) ⇒ DefaultTransform
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
#default_value ⇒ Object
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
#transform(name, value, row) ⇒ Object
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 |