Module: Madmin::Menu::Node
- Included in:
- Madmin::Menu, Item
- Defined in:
- lib/madmin/menu.rb
Instance Method Summary collapse
Instance Method Details
#add(options) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/madmin/menu.rb', line 32 def add() = .dup if (parent = .delete(:parent)) @children[parent] ||= Item.new(label: parent) @children[parent].add else item = Item.new(**) @children[item.label] = item end end |
#items ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/madmin/menu.rb', line 44 def items @children.values.sort do |a, b| result = a.position <=> b.position result = a.label <=> b.label if result == 0 # sort alphabetically for the same position result end end |