Class: SemanticNavigation::Configuration
- Inherits:
-
Object
- Object
- SemanticNavigation::Configuration
- Defined in:
- lib/semantic_navigation/configuration.rb
Constant Summary collapse
{}
- @@renderers =
{}
- @@render_styles =
{}
Class Method Summary collapse
- .navigate(id, options = {}, &block) ⇒ Object
- .navigation(name) ⇒ Object
- .register_renderer(*options) ⇒ Object
- .run(&block) ⇒ Object
- .styles_for(name) ⇒ Object
Instance Method Summary collapse
Class Method Details
.navigate(id, options = {}, &block) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/semantic_navigation/configuration.rb', line 20 def self.navigate(id, = {}, &block) [:id] = id.to_sym [:i18n_name] = "semantic_navigation.#{id}" = Core::Navigation.new() .instance_eval &block if block_given? @@navigations[id.to_sym] = end |
.navigation(name) ⇒ Object
62 63 64 |
# File 'lib/semantic_navigation/configuration.rb', line 62 def self.(name) @@navigations[name] end |
.register_renderer(*options) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/semantic_navigation/configuration.rb', line 45 def self.register_renderer(*) if .count == 1 name = [0].name.demodulize.underscore.to_sym renderer_class = [0] elsif .count == 2 name = [0].to_sym renderer_class = [1].is_a?(Symbol) ? @@renderers[[1]] : [1] end @@renderers[name] = renderer_class SemanticNavigation::HelperMethods.class_eval " def #{name}_for(name, options = {}) options[:as] = :#{name} navigation_for name, options end " end |
.run(&block) ⇒ Object
16 17 18 |
# File 'lib/semantic_navigation/configuration.rb', line 16 def self.run(&block) self.class_eval &block if block_given? end |
.styles_for(name) ⇒ Object
41 42 43 |
# File 'lib/semantic_navigation/configuration.rb', line 41 def self.styles_for(name) @@render_styles[name.to_sym] = proc end |
Instance Method Details
#render(menu_id, renderer_name, options, view_object) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/semantic_navigation/configuration.rb', line 28 def render(, renderer_name, , view_object) @@view_object = view_object renderer = @@renderers[renderer_name].new unless @@render_styles[renderer_name].nil? renderer.instance_eval &@@render_styles[renderer_name] end .keys.each{|key| renderer.send "#{key}=", [key]} renderer.name = renderer_name = @@navigations[] .mark_active .render(renderer) end |