Class: Decidim::Initiatives::Admin::AdminUsers

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

Overview

A class used to find the admins for an initiative or an organization initiatives.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(initiative, organization = nil) ⇒ AdminUsers

Initializes the class.

initiative - Decidim::Initiative organization - an organization that needs to find its initiative admins



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

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

Class Method Details

.for(initiative) ⇒ Object

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

initiative - Decidim::Initiative



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

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



18
19
20
# File 'app/queries/decidim/initiatives/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 initiative.

Returns an ActiveRecord::Relation.



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

def query
  organization.admins
end