module Metasploit::Model::NilifyBlanks
Registers before validation callback to convert the given attributes to `nil` if they are blank. This can be used to normalize empty attributes to NULL in the database so queries don't have to handle both `= ''` and `IS NULL`.
Public Instance Methods
nilify_blanks()
click to toggle source
Before validation callback to change any attributes in {ClassMethods#nilify_blank_attribute_set} that are blank to `nil`.
@return [void]
# File lib/metasploit/model/nilify_blanks.rb, line 40 def nilify_blanks self.class.nilify_blank_attribute_set.each do |attribute| value = send(attribute) if value.respond_to? :blank? and value.blank? send("#{attribute}=", nil) end end end