Class: Decidim::Consultations::Admin::AdminUsers

Inherits:
Query
  • Object
show all
Defined in:
app/queries/decidim/consultations/admin/admin_users.rb

Overview

A class used to find the admins for a consultation or an organization consultations.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(consultation, organization = nil) ⇒ AdminUsers

Initializes the class.

consultation - a consultation that needs to find its consultation admins organization - an organization that needs to find its consultation admins



26
27
28
29
# File 'app/queries/decidim/consultations/admin/admin_users.rb', line 26

def initialize(consultation, organization = nil)
  @consultation = consultation
  @organization = consultation&.organization || organization
end

Class Method Details

.for(consultation) ⇒ Object

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

consultation - a consultation that needs to find its consultation admins



11
12
13
# File 'app/queries/decidim/consultations/admin/admin_users.rb', line 11

def self.for(consultation)
  new(consultation).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 consultation admins



18
19
20
# File 'app/queries/decidim/consultations/admin/admin_users.rb', line 18

def self.for_organization(organization)
  new(nil, organization).query
end

Instance Method Details

#queryObject

Finds organization admins and the users with role admin for the given consultation.

Returns an ActiveRecord::Relation.



34
35
36
# File 'app/queries/decidim/consultations/admin/admin_users.rb', line 34

def query
  organization.admins
end