Module: ActsAsStrippableOn::Core

Included in:
ActsAsStrippableOn
Defined in:
lib/acts_as_strippable_on/core.rb

Instance Method Summary collapse

Instance Method Details

#acts_as_strippable_on(*attributes) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/acts_as_strippable_on/core.rb', line 5

def acts_as_strippable_on(*attributes)
  before_validation do
    attributes.each do |attribute|
      next if send(attribute).blank? || !send(attribute).respond_to?(:strip)
      assign_attributes(attribute => send(attribute).strip)
    end
  end
end