class Krikri::Enrichments::RemoveEmptyFields

Enrichment to strip empty strings from a value

empty = RemoveEmptyFields.new
empty.enrich_value('moomin')
# => 'moomin'
empty.enrich_value('')
# => nil

Public Instance Methods

enrich_value(value) click to toggle source
# File lib/krikri/enrichments/remove_empty_fields.rb, line 13
def enrich_value(value)
  (value.is_a?(String) && empty?(value)) ? nil : value
end

Private Instance Methods

empty?(value) click to toggle source
# File lib/krikri/enrichments/remove_empty_fields.rb, line 19
def empty?(value)
  return true if value.empty?
  return true if value =~ /\A\s*\z/
  false
end