Class: SimpleNavigation::Configuration::Builder::Navigation
- Inherits:
-
Object
- Object
- SimpleNavigation::Configuration::Builder::Navigation
- Defined in:
- lib/simple_navigation.rb
Overview
Hash structure containing simple navigation menu configuration
Defined Under Namespace
Classes: Menu
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#menus ⇒ Object
Returns the value of attribute menus.
-
#name ⇒ Object
Returns the value of attribute name.
-
#options ⇒ Object
Returns the value of attribute options.
-
#translation ⇒ Object
Returns the value of attribute translation.
Instance Method Summary collapse
-
#build ⇒ Object
render menu.
-
#initialize(name, options = {}) ⇒ Navigation
constructor
A new instance of Navigation.
-
#menu(name, *args) {|menu| ... } ⇒ Object
Create a new root menu.
Constructor Details
#initialize(name, options = {}) ⇒ Navigation
Returns a new instance of Navigation.
168 169 170 171 172 173 174 175 |
# File 'lib/simple_navigation.rb', line 168 def initialize(name, = {}) .merge!(:i18n => false) unless .has_key?(:i18n) self.translation = ['simple_navigation', name].join('.') self.id = name self. = [] self.name = name self. = end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
166 167 168 |
# File 'lib/simple_navigation.rb', line 166 def id @id end |
#menus ⇒ Object
Returns the value of attribute menus.
166 167 168 |
# File 'lib/simple_navigation.rb', line 166 def @menus end |
#name ⇒ Object
Returns the value of attribute name.
166 167 168 |
# File 'lib/simple_navigation.rb', line 166 def name @name end |
#options ⇒ Object
Returns the value of attribute options.
166 167 168 |
# File 'lib/simple_navigation.rb', line 166 def @options end |
#translation ⇒ Object
Returns the value of attribute translation.
166 167 168 |
# File 'lib/simple_navigation.rb', line 166 def translation @translation end |
Instance Method Details
#build ⇒ Object
render menu
191 192 193 194 195 196 |
# File 'lib/simple_navigation.rb', line 191 def build { :id => self.id.to_sym, :name => self.name.to_sym, :menus => self., :options => self. } end |
#menu(name, *args) {|menu| ... } ⇒ Object
Create a new root menu
178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/simple_navigation.rb', line 178 def (name, *args, &block) title = args.first.is_a?(String) ? args.first : nil = args.last.is_a?(::Hash) ? args.last : {} .merge!(:i18n => self.[:i18n]) .merge!(:translation => [self.translation, 'menus'].join('.')) .merge!(:prefix => self.id) .merge!(:class => "") unless .has_key?(:class) = Menu.new(name, title, ) yield if block self. << .build end |