Sha256: 3a9fae11ac922a11ad610f717dc704fd7ebed4bb275f1cfb153d0b852f4ae91d

Contents?: true

Size: 644 Bytes

Versions: 9

Compression:

Stored size: 644 Bytes

Contents

module Headmin
  module Filter
    class FilterView < ViewModel
      def attribute
        @association ? "#{@association}_#{@attribute}".to_sym : @attribute
      end

      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

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

      def association_model
        if @association
          reflection.klass
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
headmin-0.6.3 app/models/headmin/filter/filter_view.rb
headmin-0.6.2 app/models/headmin/filter/filter_view.rb
headmin-0.6.1 app/models/headmin/filter/filter_view.rb
headmin-0.6.0 app/models/headmin/filter/filter_view.rb
headmin-0.5.9 app/models/headmin/filter/filter_view.rb
headmin-0.5.8 app/models/headmin/filter/filter_view.rb
headmin-0.5.7 app/models/headmin/filter/filter_view.rb
headmin-0.5.6 app/models/headmin/filter/filter_view.rb
headmin-0.5.5 app/models/headmin/filter/filter_view.rb