somleng/somleng

View on GitHub
app/filters/attribute_filter/country_filter.rb

Summary

Maintainability
A
15 mins
Test Coverage
module AttributeFilter
  class CountryFilter < ApplicationFilter
    filter_params do
      optional(:country).value(:string)
    end

    def apply
      return super if filter_params.blank?

      super.where(options.fetch(:attribute_name, :country_code) => filter_params.fetch(:country))
    end
  end
end