Class: Decidim::ResourceSearch
- Inherits:
-
Searchlight::Search
- Object
- Searchlight::Search
- Decidim::ResourceSearch
- Defined in:
- app/services/decidim/resource_search.rb
Overview
This is the base class to be used by other search services. Searchlight documentation: github.com/nathanl/searchlight
Instance Method Summary collapse
-
#base_query ⇒ Object
Creates the SearchLight base query.
-
#initialize(scope, options = {}) ⇒ ResourceSearch
constructor
Initialize the Searchlight::Search base class with the options provided.
-
#search_category_id ⇒ Object
Handle the category_id filter.
Constructor Details
#initialize(scope, options = {}) ⇒ ResourceSearch
Initialize the Searchlight::Search base class with the options provided.
scope - The scope used to create the base query options - A hash of options to modify the search. These options will be
converted to methods by SearchLight so they can be used on filter #
methods. (Default {})
12 13 14 15 |
# File 'app/services/decidim/resource_search.rb', line 12 def initialize(scope, = {}) super() @scope = scope end |
Instance Method Details
#base_query ⇒ Object
Creates the SearchLight base query. Check if the option feature was provided.
19 20 21 22 23 24 25 26 27 |
# File 'app/services/decidim/resource_search.rb', line 19 def base_query # raise order_start_time.inspect raise "Missing feature" unless feature @scope .page([:page] || 1) .per([:per_page] || 12) .where(feature: feature) end |
#search_category_id ⇒ Object
Handle the category_id filter
30 31 32 |
# File 'app/services/decidim/resource_search.rb', line 30 def search_category_id query.where(decidim_category_id: category_ids) end |