Class: Gbc::Trestle::MenuHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/gbc/trestle/menu_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base, group, item) ⇒ MenuHelper

Returns a new instance of MenuHelper.



4
5
6
7
8
# File 'lib/gbc/trestle/menu_helper.rb', line 4

def initialize(base, group, item)
  @base = base
  @group = group
  @item = item
end

Instance Attribute Details

#baseObject

Returns the value of attribute base.



10
11
12
# File 'lib/gbc/trestle/menu_helper.rb', line 10

def base
  @base
end

#groupObject

Returns the value of attribute group.



10
11
12
# File 'lib/gbc/trestle/menu_helper.rb', line 10

def group
  @group
end

#itemObject

Returns the value of attribute item.



10
11
12
# File 'lib/gbc/trestle/menu_helper.rb', line 10

def item
  @item
end

Instance Method Details

#render_menuObject



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/gbc/trestle/menu_helper.rb', line 12

def render_menu
  config = load_config
  group_obj = config[group]
  item_obj = group_obj["items"][item]

  base.item(
    item, item_obj["url"],
    priority: item_priority(group_obj, item_obj),
    label: safe(item_obj["label"]), icon: icon(item_obj),
    target: target(item_obj), badge: badge(item_obj),
    group: safe(group_obj["label"])
  )
end