Class: DropdownHelper::DropdownListItem

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

Overview

TODO: support split button dropdowns

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from FormatHelper

#squeeze_n_strip

Constructor Details

#initialize(options = {}) ⇒ DropdownListItem

Returns a new instance of DropdownListItem.



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

def initialize(options={})
  @options = options
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



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

def options
  @options
end

Instance Method Details

#constructObject



14
15
16
# File 'app/helpers/dropdown_helper.rb', line 14

def construct
   :li, parse_type(options), options
end

#parse_type(options = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/helpers/dropdown_helper.rb', line 18

def parse_type(options={})
  case options[:type].try(:to_sym)
  when :link
    return link_to(options[:text], options[:link], role: :menuitem,
                   tabindex: -1)
  when :header
    prepend_class(options, 'dropdown-header')
    return options[:text]
  when :divider
    prepend_class(options, 'divider')
    options[:role] = 'separator'
  else
  end
end