Class: AbAdmin::Menu::BaseGroup

Inherits:
Object
  • Object
show all
Includes:
Utils::EvalHelpers
Defined in:
lib/ab_admin/menu/base_group.rb

Direct Known Subclasses

AbstractBuilder, Group

Instance Method Summary collapse

Methods included from Utils::EvalHelpers

#call_method_or_proc_on, #evaluate_method

Instance Method Details

#group(title, options = {}, &block) ⇒ Object


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

def group(title, options={}, &block)
  @menu_tree << Group.new(title, options, &block)
end

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

def link(title, path, options={})
  @menu_tree << Item.new(title, path, options)
end

#model(model, options = {}) ⇒ Object


11
12
13
14
15
# File 'lib/ab_admin/menu/base_group.rb', line 11

def model(model, options={})
  title = options[:title] || model.model_name.human(count: 9)
  url = options[:url] || "/admin/#{model.model_name.plural}"
  @menu_tree << Item.new(title, url, options)
end

#render_nested(template) ⇒ Object


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

def render_nested(template)
  @menu_tree.map { |item| item.render(template) }.compact.join.html_safe
end