Class: Decidim::Sortitions::SortitionSearch

Inherits:
ResourceSearch
  • Object
show all
Defined in:
app/services/decidim/sortitions/sortition_search.rb

Overview

A service to encapsualte all the logic when searching and filtering sortitions in a participatory process.

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ SortitionSearch

Public: Initializes the service. component - A Decidim::Component to get the proposals from. page - The page number to paginate the results. per_page - The number of proposals to return per page.



13
14
15
# File 'app/services/decidim/sortitions/sortition_search.rb', line 13

def initialize(options = {})
  super(Sortition.all, options)
end

Instance Method Details

#search_stateObject

Handle the state filter



18
19
20
21
22
23
24
25
26
27
# File 'app/services/decidim/sortitions/sortition_search.rb', line 18

def search_state
  case state
  when "active"
    query.active
  when "cancelled"
    query.cancelled
  else # Assume 'all'
    query
  end
end