Class: SimpleNavigation::Renderer::Base

Inherits:
Object
  • Object
show all
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

List

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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(current_navigation, current_sub_navigation=nil) #:nodoc:
  @current_navigation = current_navigation
  @current_sub_navigation = current_sub_navigation
  @controller = SimpleNavigation.controller
end

Instance Attribute Details

#controllerObject (readonly)

Returns the value of attribute controller.



13
14
15
# File 'lib/simple_navigation/renderer/base.rb', line 13

def controller
  @controller
end

#current_navigationObject (readonly)

Returns the value of attribute current_navigation.



13
14
15
# File 'lib/simple_navigation/renderer/base.rb', line 13

def current_navigation
  @current_navigation
end

#current_sub_navigationObject (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
  @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, include_sub_navigation=false)
  raise 'subclass responsibility'
end