Class: Sunrise::Config::Navigation
- Inherits:
-
Object
- Object
- Sunrise::Config::Navigation
- Includes:
- Singleton
- Defined in:
- lib/sunrise/config/navigation.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#current_name ⇒ Object
Returns the value of attribute current_name.
-
#navigations ⇒ Object
readonly
Returns the value of attribute navigations.
Class Method Summary collapse
- .method_missing(m, *args, &block) ⇒ Object
-
.navigation(name, options = nil) {|instance| ... } ⇒ Object
Configure menu items.
Instance Method Summary collapse
-
#initialize ⇒ Navigation
constructor
A new instance of Navigation.
- #item(item_name, url = nil, options = {}) ⇒ Object
Constructor Details
#initialize ⇒ Navigation
Returns a new instance of Navigation.
29 30 31 32 |
# File 'lib/sunrise/config/navigation.rb', line 29 def initialize @navigations ||= {} @current_name = :main end |
Instance Attribute Details
#current_name ⇒ Object
Returns the value of attribute current_name.
10 11 12 |
# File 'lib/sunrise/config/navigation.rb', line 10 def current_name @current_name end |
#navigations ⇒ Object (readonly)
Returns the value of attribute navigations.
11 12 13 |
# File 'lib/sunrise/config/navigation.rb', line 11 def @navigations end |
Class Method Details
.method_missing(m, *args, &block) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/sunrise/config/navigation.rb', line 20 def method_missing(m, *args, &block) if instance.respond_to?(m) instance.send(m, *args, &block) else super end end |
.navigation(name, options = nil) {|instance| ... } ⇒ Object
Configure menu items
15 16 17 18 |
# File 'lib/sunrise/config/navigation.rb', line 15 def (name, = nil) instance.current_name = name yield instance if block_given? end |
Instance Method Details
#item(item_name, url = nil, options = {}) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/sunrise/config/navigation.rb', line 34 def item(item_name, url = nil, = {}) url ||= index_path(:model_name => item_name) @navigations[current_name] ||= [] @navigations[current_name] << NavigationItem.new(item_name, url, current_name, ) end |