Method: ActiveCleaner::BaseCleaner#clean
- Defined in:
- lib/active_cleaner/base_cleaner.rb
#clean(record) ⇒ Object
Cleans the record by extracting the value of the field, cleaning it, and setting it back.
42 43 44 45 46 47 48 49 50 |
# File 'lib/active_cleaner/base_cleaner.rb', line 42 def clean(record) value = record.read_attribute_for_cleaning(attr_name) new_value = clean_value(value, record) new_value = nil if [:nilify] && nilify_value?(new_value, record) record.write_attribute_after_cleaning(attr_name, new_value) unless new_value == value end |