Class: Decidim::ParticipatoryProcesses::Admin::AdminUsers
- Inherits:
-
Query
- Object
- Query
- Decidim::ParticipatoryProcesses::Admin::AdminUsers
- Defined in:
- app/queries/decidim/participatory_processes/admin/admin_users.rb
Overview
A class used to find the admins for a participatory process including organization admins.
Class Method Summary collapse
-
.for(process) ⇒ Object
Syntactic sugar to initialize the class and return the queried objects.
-
.for_organization(organization) ⇒ Object
Syntactic sugar to initialize the class and return the queried objects.
Instance Method Summary collapse
-
#initialize(process, organization = nil) ⇒ AdminUsers
constructor
Initializes the class.
-
#query ⇒ Object
Finds organization admins and the users with role admin for the given process.
Constructor Details
#initialize(process, organization = nil) ⇒ AdminUsers
Initializes the class.
process - a process that needs to find its process admins organization - an organization that needs to find its process admins
27 28 29 30 |
# File 'app/queries/decidim/participatory_processes/admin/admin_users.rb', line 27 def initialize(process, organization = nil) @process = process @organization = process&.organization || organization end |
Class Method Details
.for(process) ⇒ Object
Syntactic sugar to initialize the class and return the queried objects.
process - a process that needs to find its process admins
12 13 14 |
# File 'app/queries/decidim/participatory_processes/admin/admin_users.rb', line 12 def self.for(process) new(process).query end |
.for_organization(organization) ⇒ Object
Syntactic sugar to initialize the class and return the queried objects.
organization - an organization that needs to find its process admins
19 20 21 |
# File 'app/queries/decidim/participatory_processes/admin/admin_users.rb', line 19 def self.for_organization(organization) new(nil, organization).query end |
Instance Method Details
#query ⇒ Object
Finds organization admins and the users with role admin for the given process.
Returns an ActiveRecord::Relation.
35 36 37 |
# File 'app/queries/decidim/participatory_processes/admin/admin_users.rb', line 35 def query organization.admins.or(processes_user_admins) end |