Sha256: 7100aa981855d30d92434e9920b4189fc991e572ba98bdf6f4d0c00b9e280f4e
Contents?: true
Size: 673 Bytes
Versions: 12
Compression:
Stored size: 673 Bytes
Contents
module ActsAsScrubbable module Scrub def scrub! if self.class.scrubbable? _updates = {} scrubbable_fields.each do |_field, value| unless self.respond_to?(_field) raise ArgumentError, "#{self.class} do not respond to #{_field}" end next if self.send(_field).blank? if ActsAsScrubbable.scrub_map.keys.include?(value) _updates[_field] = ActsAsScrubbable.scrub_map[value].call else puts "Undefined scrub: #{value} for #{self.class}#{_field}" end end self.update_columns(_updates) unless _updates.empty? end end end end
Version data entries
12 entries across 12 versions & 1 rubygems