Module: Behi::Trimify::InstanceMethods

Defined in:
lib/trimify.rb

Instance Method Summary collapse

Instance Method Details

#trimifyObject



33
34
35
36
37
38
39
40
41
42
# File 'lib/trimify.rb', line 33

def trimify
  self.class.trimify_attributes.each do |attribute, options|
    value = read_attribute(attribute) 
    if value.is_a?(String)
      value.strip!
      value = nil if (value.blank? && options[:nilify] == true)
      write_attribute(attribute, value)
    end
  end
end