Class: Kiba::Extend::Transforms::Clean::DowncaseFieldValues

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

Instance Method Summary collapse

Constructor Details

#initialize(fields:) ⇒ DowncaseFieldValues

Returns a new instance of DowncaseFieldValues.



200
201
202
# File 'lib/kiba/extend/transforms/clean.rb', line 200

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

Instance Method Details

#process(row) ⇒ Object

Parameters:

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


205
206
207
208
209
210
211
# File 'lib/kiba/extend/transforms/clean.rb', line 205

def process(row)
  @fields.each do |field|
    val = row.fetch(field)
    row[field] = val.is_a?(String) ? val.downcase : val
  end
  row
end