Class: HotwireCombobox::Listbox::Option

Inherits:
Object
  • Object
show all
Defined in:
app/presenters/hotwire_combobox/listbox/option.rb

Defined Under Namespace

Classes: Data

Instance Method Summary collapse

Constructor Details

#initialize(option) ⇒ Option

Returns a new instance of Option.



4
5
6
# File 'app/presenters/hotwire_combobox/listbox/option.rb', line 4

def initialize(option)
  @option = option.is_a?(Hash) ? Data.new(**option) : option
end

Instance Method Details

#autocompletable_asObject



16
17
18
# File 'app/presenters/hotwire_combobox/listbox/option.rb', line 16

def autocompletable_as
  option.try(:autocompletable_as) || option.try(:display)
end

#render_in(view) ⇒ Object



8
9
10
# File 'app/presenters/hotwire_combobox/listbox/option.rb', line 8

def render_in(view)
  view.tag.li content, **options
end

#valueObject



12
13
14
# File 'app/presenters/hotwire_combobox/listbox/option.rb', line 12

def value
  option.try(:value) || option.id
end