Class: Navigatrix::Renderer

Inherits:
Object
  • Object
show all
Defined in:
lib/navigatrix/renderer.rb

Defined Under Namespace

Classes: MissingStrategy

Constant Summary collapse

REGISTERED_STRATEGIES =
{
  :unordered_list   => Rendering::Strategies::List,
  :bootstrap_navbar => Rendering::Strategies::Bootstrap::Navbar,
  :bootstrap_tabs   => Rendering::Strategies::Bootstrap::Tabs
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(configuration, options) ⇒ Renderer

Returns a new instance of Renderer.



18
19
20
21
22
23
# File 'lib/navigatrix/renderer.rb', line 18

def initialize(configuration, options)
  @configuration  = configuration
  @strategy       = find_strategy(options.delete(:strategy))
  @render_context = Rendering::Context.new(options.delete(:render_context))
  @render_options = options
end

Instance Attribute Details

#configurationObject (readonly)

Returns the value of attribute configuration.



8
9
10
# File 'lib/navigatrix/renderer.rb', line 8

def configuration
  @configuration
end

#render_contextObject (readonly)

Returns the value of attribute render_context.



8
9
10
# File 'lib/navigatrix/renderer.rb', line 8

def render_context
  @render_context
end

#render_optionsObject (readonly)

Returns the value of attribute render_options.



8
9
10
# File 'lib/navigatrix/renderer.rb', line 8

def render_options
  @render_options
end

#strategyObject (readonly)

Returns the value of attribute strategy.



8
9
10
# File 'lib/navigatrix/renderer.rb', line 8

def strategy
  @strategy
end

Instance Method Details

#renderObject



25
26
27
# File 'lib/navigatrix/renderer.rb', line 25

def render
  strategy.new(item_collection.items, render_options).render
end