Class: Kiba::Extend::Transforms::Clean::ClearFields

Inherits:
Object
  • Object
show all
Defined in:
lib/kiba/extend/transforms/clean.rb

Instance Method Summary collapse

Constructor Details

#initialize(fields:, if_equals: nil) ⇒ ClearFields

Returns a new instance of ClearFields.



181
182
183
184
# File 'lib/kiba/extend/transforms/clean.rb', line 181

def initialize(fields:, if_equals: nil)
  @fields = [fields].flatten
  @if_equals = if_equals
end

Instance Method Details

#process(row) ⇒ Object

Parameters:

  • row (Hash{ Symbol => String, nil })


187
188
189
190
191
192
193
194
195
196
# File 'lib/kiba/extend/transforms/clean.rb', line 187

def process(row)
  @fields.each do |field|
    if @if_equals.nil?
      row[field] = nil
    elsif row[field] == @if_equals
      row[field] = nil
    end
  end
  row
end