Class: SimpleNavigation::Renderer::Base
- Inherits:
-
Object
- Object
- SimpleNavigation::Renderer::Base
- Includes:
- ActionView::Helpers::TagHelper, ActionView::Helpers::UrlHelper
- Defined in:
- lib/simple_navigation/renderer/base.rb
Overview
This is the base class for all renderers.
A renderer is responsible for rendering an ItemContainer (primary or a sub_navigation) and its containing items to HTML. It must be initialized with the current_navigation for the rendered ItemContainer and optionally with the current_sub_navigation (if the sub_navigation will be nested).
Direct Known Subclasses
Instance Attribute Summary collapse
-
#controller ⇒ Object
readonly
Returns the value of attribute controller.
-
#current_navigation ⇒ Object
readonly
Returns the value of attribute current_navigation.
-
#current_sub_navigation ⇒ Object
readonly
Returns the value of attribute current_sub_navigation.
Class Method Summary collapse
-
.controller_method(*methods) ⇒ Object
Delegates method calls to the controller.
Instance Method Summary collapse
-
#initialize(current_navigation, current_sub_navigation = nil) ⇒ Base
constructor
:nodoc:.
-
#render(item_container, include_sub_navigation = false) ⇒ Object
Renders the specified ItemContainer to HTML.
Constructor Details
#initialize(current_navigation, current_sub_navigation = nil) ⇒ Base
:nodoc:
28 29 30 31 32 |
# File 'lib/simple_navigation/renderer/base.rb', line 28 def initialize(, =nil) #:nodoc: @current_navigation = @current_sub_navigation = @controller = SimpleNavigation.controller end |
Instance Attribute Details
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
13 14 15 |
# File 'lib/simple_navigation/renderer/base.rb', line 13 def controller @controller end |
#current_navigation ⇒ Object (readonly)
Returns the value of attribute current_navigation.
13 14 15 |
# File 'lib/simple_navigation/renderer/base.rb', line 13 def @current_navigation end |
#current_sub_navigation ⇒ Object (readonly)
Returns the value of attribute current_sub_navigation.
13 14 15 |
# File 'lib/simple_navigation/renderer/base.rb', line 13 def @current_sub_navigation end |
Class Method Details
.controller_method(*methods) ⇒ Object
Delegates method calls to the controller.
18 19 20 21 22 |
# File 'lib/simple_navigation/renderer/base.rb', line 18 def controller_method(*methods) methods.each do |method| delegate method, :to => :controller end end |
Instance Method Details
#render(item_container, include_sub_navigation = false) ⇒ Object
Renders the specified ItemContainer to HTML.
If include_sub_navigation
is set to true, the renderer should nest the sub_navigation for the active navigation inside that navigation item.
38 39 40 |
# File 'lib/simple_navigation/renderer/base.rb', line 38 def render(item_container, =false) raise 'subclass responsibility' end |