Sha256: cdd09b3ddbc8fc623827610680e2332b58f4039cc67e455dd163fd3402e01fa9
Contents?: true
Size: 491 Bytes
Versions: 9
Compression:
Stored size: 491 Bytes
Contents
# frozen_string_literal: true module StripWhitespace def self.included(base) base.extend(ClassMethods) end module ClassMethods def strip_whitespace!(*fields) before_validation do |record| fields.each do |field| setter = "#{field}=".to_sym value = record.send(field.to_sym) if value.respond_to?(:strip) && record.respond_to?(setter) record.send(setter, value.strip) end end end end end end
Version data entries
9 entries across 9 versions & 3 rubygems