module Autostrip::Extension::ClassMethods
Public Instance Methods
autostrip(*attributes)
click to toggle source
# File lib/autostrip/extension.rb, line 22 def autostrip(*attributes) # Use prepend to be sure this runs before all other "before_validation" callbacks. before_validation prepend: true do attributes_for_autostrip(attributes).each do |attribute| value = send(attribute) if Autostrip.performable?(value) # http://www.davidverhasselt.com/set-attributes-in-activerecord/ send("#{attribute}=", Autostrip.perform(value)) end end end nil end