Class: Weaver::Menu

Inherits:
Object
  • Object
show all
Defined in:
lib/weaver/page_types/nav_page.rb

Overview

Menu used in nav pages

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMenu

Returns a new instance of Menu.



25
26
27
# File 'lib/weaver/page_types/nav_page.rb', line 25

def initialize
  @items = []
end

Instance Attribute Details

#itemsObject

Returns the value of attribute items.



24
25
26
# File 'lib/weaver/page_types/nav_page.rb', line 24

def items
  @items
end

Instance Method Details



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/weaver/page_types/nav_page.rb', line 29

def nav(name, icon = :question, url = nil, options = {}, &block)
  if url && !block
    @items << { name: name, link: url, icon: icon, options: options }
  elsif block
    menu = Menu.new
    menu.instance_eval(&block)
    @items << { name: name, menu: menu, icon: icon, options: options }
  else
    @items << { name: name, link: '#', icon: icon, options: options }
  end
end