Class: HotwireCombobox::Listbox::Item::Collection

Inherits:
Array
  • Object
show all
Defined in:
app/presenters/hotwire_combobox/listbox/item/collection.rb

Instance Method Summary collapse

Instance Method Details

#find_by_value(value) ⇒ Object



2
3
4
5
6
7
8
# File 'app/presenters/hotwire_combobox/listbox/item/collection.rb', line 2

def find_by_value(value)
  if grouped?
    flat_map { |item| item.options }.find { |option| option.value == value }
  else
    find { |option| option.value == value }
  end
end