Class: Decidim::Sortitions::SortitionSearch
- Inherits:
-
ResourceSearch
- Object
- ResourceSearch
- Decidim::Sortitions::SortitionSearch
- 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
-
#initialize(options = {}) ⇒ SortitionSearch
constructor
Public: Initializes the service.
-
#search_state ⇒ Object
Handle the state filter.
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( = {}) super(Sortition.all, ) end |
Instance Method Details
#search_state ⇒ Object
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 |