Class: Decidim::Menu
- Inherits:
- 
      Object
      
        - Object
- Decidim::Menu
 
- Defined in:
- lib/decidim/menu.rb
Overview
This class handles all logic regarding registering menus
Instance Method Summary collapse
- 
  
    
      #build_for(context)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Evaluates the registered configurations for this menu in a view context. 
- 
  
    
      #initialize(name)  ⇒ Menu 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of Menu. 
- 
  
    
      #item(label, url, options = {})  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Public: Registers a new item for the menu. 
- 
  
    
      #items  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    The weighted list of items in the menu. 
Constructor Details
#initialize(name) ⇒ Menu
Returns a new instance of Menu.
| 8 9 10 11 | # File 'lib/decidim/menu.rb', line 8 def initialize(name) @name = name @items = [] end | 
Instance Method Details
#build_for(context) ⇒ Object
Evaluates the registered configurations for this menu in a view context
| 16 17 18 19 20 | # File 'lib/decidim/menu.rb', line 16 def build_for(context) registry.configurations.each do |configuration| context.instance_exec(self, &configuration) end end | 
#item(label, url, options = {}) ⇒ Object
Public: Registers a new item for the menu
| 44 45 46 | # File 'lib/decidim/menu.rb', line 44 def item(label, url, = {}) @items << MenuItem.new(label, url, ) end | 
#items ⇒ Object
The weighted list of items in the menu
| 51 52 53 | # File 'lib/decidim/menu.rb', line 51 def items @items.select(&:visible?).sort_by(&:position) end |