Class: Menumatic::Navigation::Base
- Inherits:
-
Object
- Object
- Menumatic::Navigation::Base
- Includes:
- ActionView::Helpers
- Defined in:
- lib/menumatic/navigation.rb
Constant Summary collapse
{}
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#root ⇒ Object
Returns the value of attribute root.
Class Method Summary collapse
- .destroy_all ⇒ Object
- .get(id) ⇒ Object
- .get_instance ⇒ Object
- .group(id) ⇒ Object
- .load_navigation(navigation_id) ⇒ Object
- .navigate_to(label, destination, options = {}) ⇒ Object
Instance Method Summary collapse
-
#initialize(id) ⇒ Base
constructor
A new instance of Base.
- #items ⇒ Object
Constructor Details
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
6 7 8 |
# File 'lib/menumatic/navigation.rb', line 6 def id @id end |
#root ⇒ Object
Returns the value of attribute root.
6 7 8 |
# File 'lib/menumatic/navigation.rb', line 6 def root @root end |
Class Method Details
.destroy_all ⇒ Object
40 41 42 |
# File 'lib/menumatic/navigation.rb', line 40 def destroy_all @@navigations = {} end |
.get(id) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/menumatic/navigation.rb', line 33 def get(id) unless @@navigations.has_key?(id) Module.const_get("#{id.to_s.camelize}Navigation").get_instance end @@navigations[id] end |
.get_instance ⇒ Object
27 28 29 30 31 |
# File 'lib/menumatic/navigation.rb', line 27 def get_instance id = self.name.split("Navigation").first.underscore.to_sym @@navigations[id] = self.new(id) unless @@navigations.has_key?(id) @@navigations[id] end |
.group(id) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/menumatic/navigation.rb', line 19 def group(id) if block_given? group = self.get_instance.root.group(id, &Proc.new) else group = self.get_instance.root.group(id) end end |
.load_navigation(navigation_id) ⇒ Object
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/menumatic/navigation.rb', line 44 def () if File.exists?("app/navigation/#{}_navigation.rb") # Eager load the requested navgation (allows for use of normal if/unless statements) Menumatic::Navigation::Base.destroy_all load "app/navigation/#{}_navigation.rb" Menumatic::Navigation::Base.get() else raise Menumatic::NavigationNotFound, "app/navigation/#{}_navigation.rb" end end |
.navigate_to(label, destination, options = {}) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/menumatic/navigation.rb', line 11 def navigate_to(label, destination, = {}) if block_given? item = self.get_instance.root.navigate_to(label, destination, , &Proc.new) else item = self.get_instance.root.navigate_to(label, destination, ) end end |
Instance Method Details
#items ⇒ Object
61 62 63 |
# File 'lib/menumatic/navigation.rb', line 61 def items self.root.items end |