Class: SimplerNavigation::Renderers::Base

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers::OutputSafetyHelper, ActionView::Helpers::TagHelper, ActionView::Helpers::UrlHelper
Defined in:
lib/simpler_navigation/renderers/base.rb

Direct Known Subclasses

Breadcrumb, List

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context, item, options = {}) ⇒ Base

Returns a new instance of Base.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/simpler_navigation/renderers/base.rb', line 14

def initialize(context, item, options = {})
  @selected = {}
  @active_leaf = {}
  @show = {}

  @context = context
  @item = item
  @options = options

  @options[:level] ||= :all

  @request_fullpath = context.request.fullpath
  if @options[:request_fullpath]
    @request_fullpath = @options[:request_fullpath]
  end

  if @item.nil?
    case @options[:level]
    when :all
      @item = SimplerNavigation.config.root_item
    when Integer
      @item = find_parent_item_for_level(SimplerNavigation.config.root_item, @options[:level])
    when Range
      @item = find_parent_item_for_level(SimplerNavigation.config.root_item, @options[:level].min)
    else
      raise Error, "Invalid navigation level: #{@options[:level]}"
    end
  end
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



10
11
12
# File 'lib/simpler_navigation/renderers/base.rb', line 10

def context
  @context
end

#itemObject (readonly)

Returns the value of attribute item.



11
12
13
# File 'lib/simpler_navigation/renderers/base.rb', line 11

def item
  @item
end

#optionsObject (readonly)

Returns the value of attribute options.



12
13
14
# File 'lib/simpler_navigation/renderers/base.rb', line 12

def options
  @options
end