Sha256: f8078e9fcea1194921486ee39c98916db3b9cac0fe0175660453d6c88d5e1116
Contents?: true
Size: 912 Bytes
Versions: 1
Compression:
Stored size: 912 Bytes
Contents
module Unidom::Category::Concerns::AsAncestorCategory extend ActiveSupport::Concern included do |includer| has_many :descendant_category_rollups, class_name: 'Unidom::Category::CategoryRollup', foreign_key: :ancestor_category_id, source: :ancestor_category has_many :descendant_categories, class_name: 'Unidom::Category::Category', through: :descendant_category_rollups def roll_up!(it, at: Time.now, primary: true) rollup = descendant_category_rollups.descendant_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 roll_up?(it, at: Time.now, primary: true) # descendant_category_rollups.descendant_category_is(it).primary(primary).valid_at(now: at).alive.exists? #end end module ClassMethods end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
unidom-category-1.4 | app/models/unidom/category/concerns/as_ancestor_category.rb |