Class: Headmin::Filter::AssociationView

Inherits:
FilterView show all
Defined in:
app/models/headmin/filter/association_view.rb

Instance Method Summary collapse

Methods inherited from FilterView

#attribute

Methods inherited from ViewModel

#attributes, #initialize, #to_hash

Constructor Details

This class inherits a constructor from ViewModel

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ViewModel

Instance Method Details

#association_modelObject



20
21
22
# File 'app/models/headmin/filter/association_view.rb', line 20

def association_model
  reflection.klass
end

#base_optionsObject



4
5
6
7
8
# File 'app/models/headmin/filter/association_view.rb', line 4

def base_options
  keys = %i[name label form]
  options = to_h.slice(*keys)
  default_base_options.merge(options)
end

#collectionObject



16
17
18
# File 'app/models/headmin/filter/association_view.rb', line 16

def collection
  @collection || association_model.all.map { |record| [record.to_s, record.id] }
end

#input_optionsObject



10
11
12
13
14
# File 'app/models/headmin/filter/association_view.rb', line 10

def input_options
  keys = %i[form]
  options = to_h.slice(*keys)
  default_input_options.merge(options)
end