module FetcheableOnApi::Filterable::ClassMethods
Class methods made available to your controllers.
Public Instance Methods
filter_by(*attrs)
click to toggle source
Define a filterable attribute.
@see FetcheableOnApi::Filterable::PREDICATES_WITH_ARRAY
@param attrs [Array] options to define one or more filters. @option attrs [String, nil] :as Alias the filtered attribute @option attrs [String, nil] :class_name Override the class of the filter target @option attrs [String, nil] :with Use a specific predicate
# File lib/fetcheable_on_api/filterable.rb, line 53 def filter_by(*attrs) options = attrs.extract_options! options.symbolize_keys! options.assert_valid_keys( :as, :class_name, :with, :format, :association ) self.filters_configuration = filters_configuration.dup attrs.each do |attr| filters_configuration[attr] ||= { as: options[:as] || attr, } filters_configuration[attr].merge!(options) end end