Class: Navigation::Menu
Overview
handles adding items to a specific menu
Instance Method Summary collapse
-
#initialize(name, options = {}) ⇒ Menu
constructor
A new instance of Menu.
- #item(key, options = {}) {|NestedMenu.new(@name, key)| ... } ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(name, options = {}) ⇒ Menu
Returns a new instance of Menu.
5 6 7 8 9 |
# File 'lib/navigation/menu.rb', line 5 def initialize(name, = {}) @name = name (MENUS[@name] = ActiveSupport::OrderedHash.new).merge!( :action_menu => [:action_menu], :if => [:if]) end |
Instance Method Details
#item(key, options = {}) {|NestedMenu.new(@name, key)| ... } ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/navigation/menu.rb', line 11 def item(key, = {}, &block) key = normalize(key) MENUS[@name].merge!(key => ) # if a block is given to this method, it is # assumed that there will be nested navigation, # so yield a NestedMenu instance back to the block yield NestedMenu.new(@name, key) if block_given? end |