Module: Katalyst::Content::HasTree

Defined in:
app/models/concerns/katalyst/content/has_tree.rb

Defined Under Namespace

Classes: Builder

Instance Method Summary collapse

Instance Method Details

#treeObject

Constructs a tree from an ordered list of items with depth.

* items that have higher depth than their predecessor are nested as `children`.
* items with the same depth become siblings.


9
10
11
# File 'app/models/concerns/katalyst/content/has_tree.rb', line 9

def tree
  items.reduce(Builder.new, &:add).tree
end