Class: ActiveAdmin::Views::MenuItem
- Defined in:
 - lib/active_admin/views/components/menu_item.rb
 
Overview
Arbre component used to render ActiveAdmin::MenuItem
Instance Attribute Summary collapse
- 
  
    
      #label  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute label.
 - 
  
    
      #priority  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute priority.
 - 
  
    
      #url  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute url.
 
Instance Method Summary collapse
- 
  
    
      #<=>(other)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Sorts by priority first, then alphabetically by label if needed.
 - #build(item, options = {}) ⇒ Object
 - #tag_name ⇒ Object
 - #to_s ⇒ Object
 - #visible? ⇒ Boolean
 
Instance Attribute Details
#label ⇒ Object (readonly)
Returns the value of attribute label.
      8 9 10  | 
    
      # File 'lib/active_admin/views/components/menu_item.rb', line 8 def label @label end  | 
  
#priority ⇒ Object (readonly)
Returns the value of attribute priority.
      10 11 12  | 
    
      # File 'lib/active_admin/views/components/menu_item.rb', line 10 def priority @priority end  | 
  
#url ⇒ Object (readonly)
Returns the value of attribute url.
      9 10 11  | 
    
      # File 'lib/active_admin/views/components/menu_item.rb', line 9 def url @url end  | 
  
Instance Method Details
#<=>(other) ⇒ Object
Sorts by priority first, then alphabetically by label if needed.
      38 39 40 41  | 
    
      # File 'lib/active_admin/views/components/menu_item.rb', line 38 def <=>(other) result = priority <=> other.priority result == 0 ? label <=> other.label : result end  | 
  
#build(item, options = {}) ⇒ Object
      12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31  | 
    
      # File 'lib/active_admin/views/components/menu_item.rb', line 12 def build(item, = {}) super(.merge(id: item.id)) @label = helpers.render_in_context self, item.label @url = helpers.render_in_context self, item.url @priority = item.priority @submenu = nil add_class "current" if item.current? assigns[:current_tab] if url text_node link_to label, url, **item. else span label, item. end if item.items.any? add_class "has_nested" @submenu = (item) end end  | 
  
#tag_name ⇒ Object
      33 34 35  | 
    
      # File 'lib/active_admin/views/components/menu_item.rb', line 33 def tag_name "li" end  | 
  
#to_s ⇒ Object
      47 48 49  | 
    
      # File 'lib/active_admin/views/components/menu_item.rb', line 47 def to_s visible? ? super : "" end  | 
  
#visible? ⇒ Boolean
      43 44 45  | 
    
      # File 'lib/active_admin/views/components/menu_item.rb', line 43 def visible? url.nil? || real_url? || @submenu && @submenu.children.any? end  |