Sha256: 93b659221275fdaa64502ec8820952ab22747fce6940e6b41accbf2922577c34
Contents?: true
Size: 720 Bytes
Versions: 19
Compression:
Stored size: 720 Bytes
Contents
module Spina::Api class NavigationSerializer < BaseSerializer set_type :navigation attributes :name, :label attribute :tree do |navigation| items_to_tree(navigation.navigation_items.sorted.roots.in_menu.live.joins(:page)) end class << self def items_to_tree(collection) collection.map do |item| { depth: item.depth, page: { id: item.page_id, menu_title: item.menu_title, materialized_path: item.materialized_path }, children: items_to_tree(item.children.sorted.in_menu.live.joins(:page)) } end end end end end
Version data entries
19 entries across 19 versions & 1 rubygems