[NEW] Plugin to strip leading and trailing blanks from attributes.
[redhillonrails.git] / vendor / plugins / stripper / lib / red_hill_consulting / acts / stripper / active_record / base.rb
blobfd506111c4f140a3f585503cddd29e9c174b7373
1 module RedHillConsulting::Acts::Stripper::ActiveRecord
2   module Base
3     def self.included(base)
4       base.alias_method_chain :write_attribute, :stripper
5     end
7     def write_attribute_with_stripper(attr_name, value)
8       value = value.strip if value.respond_to?(:strip)
9       value = nil if value.blank?
10       write_attribute_without_stripper(attr_name, value)
11     end
12   end
13 end