Class: Decidim::ParticipatoryProcesses::ParticipatoryProcessesByGroup

Inherits:
Query
  • Object
show all
Defined in:
app/queries/decidim/participatory_processes/participatory_processes_by_group.rb

Overview

A class used to find the ParticipatoryProcesses from a ProcessGroup.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(process_group) ⇒ ParticipatoryProcessesByGroup

Initializes the class.



13
14
15
# File 'app/queries/decidim/participatory_processes/participatory_processes_by_group.rb', line 13

def initialize(process_group)
  @process_group = process_group
end

Class Method Details

.for(process_group) ⇒ Object

Syntactic sugar to initialize the class and return the queried objects.



8
9
10
# File 'app/queries/decidim/participatory_processes/participatory_processes_by_group.rb', line 8

def self.for(process_group)
  new(process_group).query
end

Instance Method Details

#processesObject



17
18
19
# File 'app/queries/decidim/participatory_processes/participatory_processes_by_group.rb', line 17

def processes
  ParticipatoryProcess
end

#queryObject



21
22
23
24
25
# File 'app/queries/decidim/participatory_processes/participatory_processes_by_group.rb', line 21

def query
  return processes.all unless @process_group

  processes.where(participatory_process_group: @process_group)
end