Sha256: 5548b33028fc7b970b6203c4fca121d25e42e7d0ac6577d813934d852766c761
Contents?: true
Size: 609 Bytes
Versions: 2
Compression:
Stored size: 609 Bytes
Contents
module NillyVanilly module Nillify def self.included(base) base.extend ClassMethods end module ClassMethods def nillify(*attributes) class_eval do before_save :nillification end cattr_accessor :nillify_attributes self.nillify_attributes = attributes include InstanceMethods end end module InstanceMethods def nillification for attribute in self.class.nillify_attributes self.send("#{attribute}=", nil) if self.send(attribute) == "" end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
nilly_vanilly-0.2.0 | lib/nilly_vanilly/nillify.rb |
nilly_vanilly-0.1.0 | lib/nilly_vanilly/nillify.rb |