Class: ActiveAdmin::Menu

Inherits:
Object show all
Defined in:
lib/active_admin/menu.rb

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ Menu

Returns a new instance of Menu.

Yields:

  • (_self)

Yield Parameters:



4
5
6
7
# File 'lib/active_admin/menu.rb', line 4

def initialize
  @items = []
  yield(self) if block_given?
end

Instance Method Details

#[](name) ⇒ Object



13
14
15
# File 'lib/active_admin/menu.rb', line 13

def [](name)
  items.find{ |i| i.name == name }
end

#add(*args, &block) ⇒ Object



9
10
11
# File 'lib/active_admin/menu.rb', line 9

def add(*args, &block)
  @items << MenuItem.new(*args, &block)
end

#find_by_url(url) ⇒ Object



21
22
23
# File 'lib/active_admin/menu.rb', line 21

def find_by_url(url)
  recursive_find_by_url(items, url)
end

#itemsObject



17
18
19
# File 'lib/active_admin/menu.rb', line 17

def items
  @items.sort
end