Sha256: 552476c3b5da2ca1e5e81df8daeff48d81d6f4150ac9685a8e8e9423a0a39963
Contents?: true
Size: 1.04 KB
Versions: 1
Compression:
Stored size: 1.04 KB
Contents
module Unidom module Category module Concerns module AsDescendantCategory extend ActiveSupport::Concern included do |includer| has_many :ancestor_category_rollups, class_name: 'Unidom::Category::CategoryRollup', foreign_key: :descendant_category_id, source: :descendant_category has_many :ancestor_categories, class_name: 'Unidom::Category::Category', through: :ancestor_category_rollups def is_rolled_up!(it, at: Time.now, primary: true) rollup = ancestor_category_rollups.ancestor_category_is(it).valid_at(now: at).alive.first_or_create! elemental: primary, opened_at: at rollup.elemental = primary if rollup.elemental!=primary rollup.save! rollup end def is_rolled_up?(it, at: Time.now, primary: true) ancestor_category_rollups.ancestor_category_is(it).primary(primary).valid_at(now: at).alive.exists? end end module ClassMethods end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
unidom-category-2.0.1 | app/models/unidom/category/concerns/as_descendant_category.rb |