Class: FoxTail::Select::OptionComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/fox_tail/select/option_component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, html_attributes = {}) ⇒ OptionComponent

Returns a new instance of OptionComponent.



8
9
10
11
# File 'app/components/fox_tail/select/option_component.rb', line 8

def initialize(value, html_attributes = {})
  @value = value
  super(html_attributes)
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



4
5
6
# File 'app/components/fox_tail/select/option_component.rb', line 4

def value
  @value
end

Instance Method Details

#before_renderObject



13
14
15
16
17
18
# File 'app/components/fox_tail/select/option_component.rb', line 13

def before_render
  super

  html_attributes[:value] = value
  html_attributes[:selected] = :selected if selected?
end

#callObject



20
21
22
# File 'app/components/fox_tail/select/option_component.rb', line 20

def call
   :option, content? ? content : value.to_s.humanize, html_attributes
end