Class: Katalyst::Navigation::Menu::Version
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- Katalyst::Navigation::Menu::Version
- Includes:
- HasTree
- Defined in:
- app/models/katalyst/navigation/menu.rb
Instance Method Summary collapse
Methods included from HasTree
Instance Method Details
#items ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'app/models/katalyst/navigation/menu.rb', line 117 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 |