Class: Brainstem::QueryStrategies::FilterAndSearch

Inherits:
BaseStrategy
  • Object
show all
Defined in:
lib/brainstem/query_strategies/filter_and_search.rb

Instance Method Summary collapse

Methods inherited from BaseStrategy

#evaluate_scope, #initialize

Constructor Details

This class inherits a constructor from Brainstem::QueryStrategies::BaseStrategy

Instance Method Details

#execute(scope) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/brainstem/query_strategies/filter_and_search.rb', line 4

def execute(scope)
  ordered_search_ids = run_search(scope, filter_includes.map(&:name))
  scope = scope.where(id: ordered_search_ids)
  scope = @options[:primary_presenter].apply_filters_to_scope(scope, @options[:params], @options)
  scope = @options[:primary_presenter].apply_ordering_to_scope(scope, @options[:params])
  count = scope.count
  scope = paginate(scope)
  primary_models = evaluate_scope(scope)

  [primary_models, count]
end