Class: Tenon::GenericFilterer

Inherits:
BaseFilterer show all
Defined in:
app/filterers/tenon/generic_filterer.rb

Overview

Returns an ActiveRecord::Collection filtered based on the presence of params and the quick_search_fields passed into the initializer

quick_search_fields should be an array of strings including table name eg. ['title', 'description']

Instance Attribute Summary

Attributes inherited from BaseFilterer

#params, #scope

Instance Method Summary collapse

Constructor Details

#initialize(scope, params, quick_search_fields) ⇒ GenericFilterer

Returns a new instance of GenericFilterer.



7
8
9
10
# File 'app/filterers/tenon/generic_filterer.rb', line 7

def initialize(scope, params, quick_search_fields)
  @quick_search_fields = quick_search_fields
  super(scope, params)
end

Instance Method Details

#filterObject



12
13
14
15
# File 'app/filterers/tenon/generic_filterer.rb', line 12

def filter
  quick_search if params[:q].present?
  scope
end