Module: JSONAPI::Support::RegularFilters

Included in:
CollectionQuery
Defined in:
lib/json_api/support/concerns/regular_filters.rb

Instance Method Summary collapse

Instance Method Details

#apply_regular_filters(scope) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/json_api/support/concerns/regular_filters.rb', line 6

def apply_regular_filters(scope)
  return scope if filter_params.empty?

  regular_filters = filter_params.reject { |k, _v| k.to_s.include?(".") }
  return scope if regular_filters.empty?

  regular_filters.reduce(scope) do |current_scope, (filter_name, filter_value)|
    apply_regular_filter(current_scope, filter_name.to_s, filter_value)
  end
end