Module: Katalyst::Content::Version
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/concerns/katalyst/content/version.rb
Instance Method Summary collapse
Instance Method Details
#ensure_items_exists ⇒ Object
20 21 22 |
# File 'app/models/concerns/katalyst/content/version.rb', line 20 def ensure_items_exists parent.errors.add(:items, :missing_item) unless items.all?(&:present?) end |
#items ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/models/concerns/katalyst/content/version.rb', line 24 def items # support building menus in memory # requires that items are added in order and index and depth are set return parent.items unless parent.persisted? items = parent.items.where(id: nodes.map(&:id)).index_by(&:id) nodes.map do |node| items[node.id]&.tap do |item| item.index = node.index item.depth = node.depth end end end |
#text ⇒ Object
38 39 40 |
# File 'app/models/concerns/katalyst/content/version.rb', line 38 def text items.filter_map(&:to_plain_text).join("\n") end |