Class: HotwireCombobox::Listbox::Item

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(view, options, render_in:, include_blank:, **custom_methods) ⇒ Item

Returns a new instance of Item.



8
9
10
11
12
13
14
# File 'app/presenters/hotwire_combobox/listbox/item.rb', line 8

def initialize(view, options, render_in:, include_blank:, **custom_methods)
  @view = view
  @options = options
  @render_in = render_in
  @include_blank = include_blank
  @custom_methods = custom_methods
end

Class Method Details

.collection_for(view, options, render_in:, include_blank:, **custom_methods) ⇒ Object



3
4
5
# File 'app/presenters/hotwire_combobox/listbox/item.rb', line 3

def collection_for(view, options, render_in:, include_blank:, **custom_methods)
  new(view, options, render_in: render_in, include_blank: include_blank, **custom_methods).collection
end

Instance Method Details

#collectionObject



16
17
18
19
20
# File 'app/presenters/hotwire_combobox/listbox/item.rb', line 16

def collection
  items = groups_or_options
  items.unshift(blank_option) if include_blank.present?
  Collection.new items
end