Class: Decidim::MenuRegistry
- Inherits:
 - 
      Object
      
        
- Object
 - Decidim::MenuRegistry
 
 
- Defined in:
 - lib/decidim/menu_registry.rb
 
Overview
This class handles all logic regarding registering menus
Instance Attribute Summary collapse
- 
  
    
      #configurations  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute configurations.
 
Class Method Summary collapse
- 
  
    
      .create(name)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Creates an empty named menu.
 - 
  
    
      .destroy(name)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Destroys a named menu.
 - 
  
    
      .find(name)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Finds a menu by name.
 - 
  
    
      .register(name, &block)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Finds a menu by name or creates it if it does not exist.
 
Instance Method Summary collapse
- 
  
    
      #initialize  ⇒ MenuRegistry 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of MenuRegistry.
 
Constructor Details
#initialize ⇒ MenuRegistry
Returns a new instance of MenuRegistry.
      61 62 63  | 
    
      # File 'lib/decidim/menu_registry.rb', line 61 def initialize @configurations = [] end  | 
  
Instance Attribute Details
#configurations ⇒ Object (readonly)
Returns the value of attribute configurations.
      59 60 61  | 
    
      # File 'lib/decidim/menu_registry.rb', line 59 def configurations @configurations end  | 
  
Class Method Details
.create(name) ⇒ Object
Creates an empty named menu
      39 40 41  | 
    
      # File 'lib/decidim/menu_registry.rb', line 39 def create(name) all[name] = new end  | 
  
.destroy(name) ⇒ Object
Destroys a named menu
      48 49 50  | 
    
      # File 'lib/decidim/menu_registry.rb', line 48 def destroy(name) all[name] = nil end  | 
  
.find(name) ⇒ Object
Finds a menu by name
      30 31 32  | 
    
      # File 'lib/decidim/menu_registry.rb', line 30 def find(name) all[name] end  | 
  
.register(name, &block) ⇒ Object
Finds a menu by name or creates it if it does not exist. Optionally, registers a MenuItem DSL block for the menu.
      17 18 19 20 21 22 23  | 
    
      # File 'lib/decidim/menu_registry.rb', line 17 def register(name, &block) = find(name) || create(name) .configurations << block end  |