Module: Trimmable::ClassMethods

Defined in:
lib/trimmable.rb

Instance Method Summary collapse

Instance Method Details

#trimmable_attributes(*attributes_list) ⇒ Object


7
8
9
10
11
12
13
# File 'lib/trimmable.rb', line 7

def trimmable_attributes *attributes_list
  before_validation do |model|
    attributes_list.each do |attribute|
      model[attribute] = model[attribute].strip if model[attribute].respond_to?(:strip)
    end
  end
end