Class: FoxTail::Select::OptionComponent
- Inherits:
-
BaseComponent
- Object
- BaseComponent
- FoxTail::Select::OptionComponent
- Defined in:
- app/components/fox_tail/select/option_component.rb
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #before_render ⇒ Object
- #call ⇒ Object
-
#initialize(value, html_attributes = {}) ⇒ OptionComponent
constructor
A new instance of OptionComponent.
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
#value ⇒ Object (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_render ⇒ Object
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 |
#call ⇒ Object
20 21 22 |
# File 'app/components/fox_tail/select/option_component.rb', line 20 def call content_tag :option, content? ? content : value.to_s.humanize, html_attributes end |