Class: NavHelper::NavCreator

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers, FormatHelper
Defined in:
app/helpers/nav_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from FormatHelper

#prepend_class, #squeeze_n_strip

Constructor Details

#initialize(options) ⇒ NavCreator

Returns a new instance of NavCreator.



10
11
12
# File 'app/helpers/nav_helper.rb', line 10

def initialize(options)
  @options = options
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



7
8
9
# File 'app/helpers/nav_helper.rb', line 7

def options
  @options
end

#output_bufferObject

Returns the value of attribute output_buffer.



8
9
10
# File 'app/helpers/nav_helper.rb', line 8

def output_buffer
  @output_buffer
end

Instance Method Details

#renderObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/helpers/nav_helper.rb', line 14

def render
  nav_options = {
    as:     options.delete(:as).presence || :tabs,
    layout: options.delete(:layout).presence
  }

  tag    = options.delete(:tag).try(:to_sym).presence || :ul
  active = options.delete(:active)

  prepend_class(options, 'nav', build_nav_class(nav_options))

  options.merge!(data: {bui: 'nav', active_el_locator: active})

  [tag, options]
end