Class: ActiveCleaner::Utf8mb3Cleaner

Inherits:
BaseCleaner show all
Defined in:
lib/active_cleaner/utf8mb3_cleaner.rb

Instance Attribute Summary

Attributes inherited from BaseCleaner

#attr_name, #options

Instance Method Summary collapse

Methods inherited from BaseCleaner

#==, #clean, #initialize, kind, #kind, #nilify_value?

Constructor Details

This class inherits a constructor from ActiveCleaner::BaseCleaner

Instance Method Details

#clean_value(old_value, record = nil) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/active_cleaner/utf8mb3_cleaner.rb', line 6

def clean_value(old_value, record=nil)
  case old_value
  when String
    old_value.each_char.select { |char| char.bytesize < 4 }.join('')
  else
    old_value
  end
end