Class: Kiba::Extend::Transforms::Append::NilFields
- Inherits:
-
Object
- Object
- Kiba::Extend::Transforms::Append::NilFields
- Defined in:
- lib/kiba/extend/transforms/append/nil_fields.rb
Overview
Adds the given field(s) to the row with nil value if they do not already exist in row
Instance Method Summary collapse
-
#initialize(fields:) ⇒ NilFields
constructor
A new instance of NilFields.
-
#process(row) ⇒ Object
Constructor Details
#initialize(fields:) ⇒ NilFields
Returns a new instance of NilFields.
22 23 24 |
# File 'lib/kiba/extend/transforms/append/nil_fields.rb', line 22 def initialize(fields:) @fields = [fields].flatten end |
Instance Method Details
#process(row) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/kiba/extend/transforms/append/nil_fields.rb', line 27 def process(row) @fields.each do |field| row[field] = nil unless row.key?(field) end row end |