Class: Admix::Navigation::NavBar

Inherits:
Object
  • Object
show all
Defined in:
lib/admix/navigation/navbar.rb

Constant Summary collapse

Array.new
Array.new

Class Method Summary collapse

Class Method Details

.add(*menus) ⇒ Object



27
28
29
30
31
# File 'lib/admix/navigation/navbar.rb', line 27

def self.add(*menus)
  menus.each do |menu|
    self.add_menu menu
  end
end

.add_menu(menu) ⇒ Object



33
34
35
36
37
# File 'lib/admix/navigation/navbar.rb', line 33

def self.add_menu(menu)
  if menu.is_a? Admix::Navigation::Menu
    @@menus << menu
  end
end

.allObject



69
70
71
# File 'lib/admix/navigation/navbar.rb', line 69

def self.all
  @@menus
end

.clear!Object



73
74
75
76
# File 'lib/admix/navigation/navbar.rb', line 73

def self.clear!
  @@menus  = []
  @@menus_procs  = []
end

.deeply_find(key, menu) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/admix/navigation/navbar.rb', line 53

def self.deeply_find(key, menu)
  return false if menu.children.length == 0

  i = 0
  while i < menu.children.length do
    submenu = menu.children[i]
    self.deeply_find(key, submenu)

    return submenu if submenu.key == key

    i += 1
  end

  false
end

.find(key) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/admix/navigation/navbar.rb', line 39

def self.find(key)
  @@menus.each do |menu|
    submenu = self.deeply_find(key, menu)

    if submenu
      yield submenu
      return submenu
    elsif menu.key == key
      yield menu
      return menu
    end
  end
end

.insert_post_menusObject



16
17
18
19
20
21
22
23
24
25
# File 'lib/admix/navigation/navbar.rb', line 16

def self.insert_post_menus
  Rails.application.railties.engines.select do |e|
    if e.respond_to?(:navigation)
      e.navigation
    end
  end
  @@menus_procs.each do |proc|
    proc.call()
  end
end

.post_menu(&block) ⇒ Object



12
13
14
# File 'lib/admix/navigation/navbar.rb', line 12

def self.post_menu(&block)
  @@menus_procs << block
end