Sha256: 4677431c3a202083ce1fe2f1341fcf28d6e028e1304f6eda005d1fa39b94b6f8
Contents?: true
Size: 531 Bytes
Versions: 1
Compression:
Stored size: 531 Bytes
Contents
require "nullifyable/version" require "active_record" module Nullifyable extend ActiveSupport::Concern module ClassMethods attr_reader :nullifyable_attributes private def nullify(*attributes) @nullifyable_attributes = attributes end end included do before_save :nullify_blank_fields end private def nullify_blank_fields self.class.nullifyable_attributes.each do |attr| self[attr] = nil if self[attr].blank? end if self.class.nullifyable_attributes.present? end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
nullifyable-0.1.0 | lib/nullifyable.rb |