Sha256: 8643fe5e2de70fd88a1b429ca258ed8ec67e5b612853321f10c4d821882c40d1
Contents?: true
Size: 515 Bytes
Versions: 6
Compression:
Stored size: 515 Bytes
Contents
module Enjoy::Gallery::Gallerable extend ActiveSupport::Concern module ClassMethods def enjoy_gallerable_field(name = :enjoy_gallerable, opts = {}) class_name = opts.delete(:class_name) class_name ||= "Enjoy::Gallery::Gallery" belongs_to name, polymorphic: true class_eval <<-EVAL before_save do self.#{name}_id = nil if self.#{name}_type.nil? self.#{name}_type = nil if self.#{name}_id.nil? self end EVAL end end end
Version data entries
6 entries across 6 versions & 1 rubygems