Sha256: 00f20a905b0f7817c3d1b74db156d513afb0334f1d82bbca208ce60ce8c10026
Contents?: true
Size: 918 Bytes
Versions: 3
Compression:
Stored size: 918 Bytes
Contents
module Lolita module Menu module NestedTree class TreeBuilder attr_reader :items, :root def initialize(klass, items, scope_attributes = {}) @klass = klass @scope_attributes = scope_attributes @root = @klass.find_or_create_root(@scope_attributes) @items = items.is_a?(Hash) ? items.values : items @items.map! do |item| Lolita::Menu::NestedTree::BranchBuilder.new(@root, item) end end def item_ids @items.map { |item| item.value_for(:item_id) } end def update_items @items.each do |item| @klass.update_item(item) end @klass.remove_items(deleted_items) end private def deleted_items @klass.with_tree_scope(@scope_attributes).all_tree_item_ids - item_ids end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
lolita-menu-0.4.2 | lib/lolita-menu/nested_tree/tree_builder.rb |
lolita-menu-0.4.1 | lib/lolita-menu/nested_tree/tree_builder.rb |
lolita-menu-0.4.0 | lib/lolita-menu/nested_tree/tree_builder.rb |