Class: Headmin::Filter::FilterView

Inherits:
ViewModel
  • Object
show all
Defined in:
app/models/headmin/filter/filter_view.rb

Instance Method Summary collapse

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



18
19
20
21
22
# File 'app/models/headmin/filter/filter_view.rb', line 18

def association_model
  if @association
    reflection.klass
  end
end

#attributeObject



4
5
6
# File 'app/models/headmin/filter/filter_view.rb', line 4

def attribute
  @association ? "#{@association}_#{@attribute}".to_sym : @attribute
end

#labelObject



8
9
10
# File 'app/models/headmin/filter/filter_view.rb', line 8

def label
  @label || I18n.t("attributes.#{attribute}", default: @association ? "#{association_model.model_name.human(count: 1)} - #{association_model.human_attribute_name(@attribute)}" : name.to_s)
end

#reflectionObject



12
13
14
15
16
# File 'app/models/headmin/filter/filter_view.rb', line 12

def reflection
  if @association
    form.object.class.reflect_on_association(@association)
  end
end