Class: Headmin::Filter::FilterView
- Defined in:
- app/models/headmin/filter/filter_view.rb
Direct Known Subclasses
AssociationCountView, AssociationView, BooleanView, DateView, FieldView, NumberView, OptionsView, TextView
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_model ⇒ Object
18 19 20 21 22 |
# File 'app/models/headmin/filter/filter_view.rb', line 18 def association_model if @association reflection.klass end end |
#attribute ⇒ Object
4 5 6 |
# File 'app/models/headmin/filter/filter_view.rb', line 4 def attribute @association ? "#{@association}_#{@attribute}".to_sym : @attribute end |
#label ⇒ Object
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 |
#reflection ⇒ Object
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 |