Class: Iqvoc::Configuration::Navigation
- Inherits:
-
Object
- Object
- Iqvoc::Configuration::Navigation
- Defined in:
- lib/iqvoc/configuration/navigation.rb
Class Method Summary collapse
- .add(item, position = nil) ⇒ Object
- .add_grouped(item, position = nil) ⇒ Object
- .items ⇒ Object
-
.remove(name) ⇒ Object
removes first item matching name.
-
.setup_extension_group(position) ⇒ Object
Setup an empty navigation group for extensions Returns index for the new (or existing) group, so add_grouped can use the index to insert it's item under the group.
Class Method Details
.add(item, position = nil) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/iqvoc/configuration/navigation.rb', line 28 def self.add(item, position = nil) if position items.insert(position, item) else items << item end end |
.add_grouped(item, position = nil) ⇒ Object
42 43 44 45 |
# File 'lib/iqvoc/configuration/navigation.rb', line 42 def self.add_grouped(item, position = nil) index = setup_extension_group(position) items[index][:items] << item end |
.items ⇒ Object
24 25 26 |
# File 'lib/iqvoc/configuration/navigation.rb', line 24 def self.items Iqvoc. end |
.remove(name) ⇒ Object
removes first item matching name
37 38 39 40 |
# File 'lib/iqvoc/configuration/navigation.rb', line 37 def self.remove(name) item = items.find { || [:text] == name} items.delete(item) end |
.setup_extension_group(position) ⇒ Object
Setup an empty navigation group for extensions Returns index for the new (or existing) group, so add_grouped can use the index to insert it's item under the group
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/iqvoc/configuration/navigation.rb', line 51 def self.setup_extension_group(position) group = { text: proc { t('txt.views.navigation.extensions') }, items: [] } if position && !items[position][:items] items.insert(position, group) elsif position && items[position][:items] return position else items << group end items.index(group) end |