Class: ActiveAdmin::Menu
Instance Method Summary collapse
- #[](name) ⇒ Object
- #add(*args, &block) ⇒ Object
- #find_by_url(url) ⇒ Object
-
#initialize {|_self| ... } ⇒ Menu
constructor
A new instance of Menu.
- #items ⇒ Object
Constructor Details
#initialize {|_self| ... } ⇒ Menu
Returns a new instance of Menu.
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 |
#items ⇒ Object
17 18 19 |
# File 'lib/active_admin/menu.rb', line 17 def items @items.sort end |