Class: Madmin::Menu

Inherits:
Object
  • Object
show all
Includes:
Node
Defined in:
lib/madmin/menu.rb

Defined Under Namespace

Modules: Node Classes: Item

Instance Method Summary collapse

Methods included from Node

#add, #items

Constructor Details

#initializeMenu

Returns a new instance of Menu.



3
4
5
# File 'lib/madmin/menu.rb', line 3

def initialize
  @children = {}
end

Instance Method Details

#before_render(&block) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/madmin/menu.rb', line 11

def before_render(&block)
  if block_given?
    @before_render = block
  else
    @before_render
  end
end

#render(&block) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/madmin/menu.rb', line 19

def render(&block)
  instance_eval(&@before_render) if @before_render

  # Ensure all the resources have been added to the menu
  Madmin.resources.each do |resource|
    next if resource.menu_options == false
    add resource.menu_options
  end

  items.each(&block)
end

#resetObject



7
8
9
# File 'lib/madmin/menu.rb', line 7

def reset
  @children = {}
end