Module: SteelWheel::Filters::InstanceMethods

Defined in:
lib/steel_wheel/filters.rb

Overview

rubocop:disable Style/Documentation

Instance Method Summary collapse

Instance Method Details

#apply_filters(scope, search_params) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/steel_wheel/filters.rb', line 25

def apply_filters(scope, search_params)
  search_params.each do |key, value|
    filter_method = "filter_by_#{key}"
    raise SteelWheel::FilterNotImplementedError, key unless respond_to?(filter_method)

    scope = send(filter_method, scope, value) if value.present?
  end
  scope
end