Sha256: 27125f42ed08dfa2077f7bc272e80ca694b3d62f57789fe02c11d5a65f3afc0b
Contents?: true
Size: 691 Bytes
Versions: 5
Compression:
Stored size: 691 Bytes
Contents
module Polyblock module HasPolyblock extend ActiveSupport::Concern included do end module ClassMethods def has_polyblock(name, options={}) defaults = {:class_name => "Polyblock::Block", :as => :contentable, :dependent => :destroy} has_one name, -> { where(:name => name) }, defaults.merge(options) accepts_nested_attributes_for name include Polyblock::HasPolyblock::LocalInstanceMethods end end module LocalInstanceMethods def has_polyblock_content_for?(name) !self.send(name).nil? and !self.send(name).content.blank? end end end end ActiveRecord::Base.send :include, Polyblock::HasPolyblock
Version data entries
5 entries across 5 versions & 1 rubygems