class Udongo::Pages::Tree
Public Class Methods
new(context)
click to toggle source
# File lib/udongo/pages/tree.rb, line 3 def initialize(context) @context = context end
Public Instance Methods
data(parent_id: nil)
click to toggle source
# File lib/udongo/pages/tree.rb, line 7 def data(parent_id: nil) Page.where(parent_id: parent_id).inject([]) do |results, page| hash = Udongo::Pages::TreeNode.new(@context, page).data hash[:children] = data(parent_id: page.id) if page.children.any? results << hash end end