Class: Navigation::NestedMenu
- Defined in:
- lib/navigation/nested_menu.rb
Overview
handles adding nested menu items to a parent menu item
Instance Method Summary collapse
-
#initialize(menu, parent) ⇒ NestedMenu
constructor
A new instance of NestedMenu.
- #item(key, options = {}) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(menu, parent) ⇒ NestedMenu
Returns a new instance of NestedMenu.
5 6 7 8 9 10 11 |
# File 'lib/navigation/nested_menu.rb', line 5 def initialize(, parent) @menu, @parent = , parent # the entire nested menu is stored as a nested ordered hash # since we want multiple items in the same hash, only initialize once MENUS[@menu][@parent][SUBMENU] = ActiveSupport::OrderedHash.new unless MENUS[@menu][@parent].has_key?(SUBMENU) end |
Instance Method Details
#item(key, options = {}) ⇒ Object
13 14 15 16 17 |
# File 'lib/navigation/nested_menu.rb', line 13 def item(key, = {}) # only support one level of nesting (the action-level) raise InvalkeyBlock, InvalkeyBlock. if block_given? MENUS[@menu][@parent][SUBMENU].merge!(normalize(key) => ) end |