class Navigatrix::Renderer

Attributes

configuration[R]
render_context[R]
render_options[R]
strategy[R]

Public Class Methods

new(configuration, options) click to toggle source
# File lib/navigatrix/renderer.rb, line 11
def initialize(configuration, options)
  @configuration  = configuration
  @render_context = Rendering::Context.new(options.delete(:render_context))
  @render_options = options
end

Public Instance Methods

render() click to toggle source
# File lib/navigatrix/renderer.rb, line 17
def render
  strategy.new(item_collection.items, list_options, item_options).render
end

Private Instance Methods

item_collection() click to toggle source
# File lib/navigatrix/renderer.rb, line 23
def item_collection
  ItemCollection.new(configuration, render_context)
end
item_options() click to toggle source
# File lib/navigatrix/renderer.rb, line 41
def item_options
  render_options
    .slice(:active_class, :inactive_class)
    .merge(render_options.fetch(:item, {}))
end
list_options() click to toggle source
# File lib/navigatrix/renderer.rb, line 35
def list_options
  base = render_options[:html_attributes]
  (base ? {html_attributes: base} : {})
    .merge(render_options.fetch(:list, {}))
end
strategy_name() click to toggle source
# File lib/navigatrix/renderer.rb, line 31
def strategy_name
  render_options.fetch(:list, {})[:renderer]
end