Class: Decidim::Assemblies::Admin::AdminUsers

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

Overview

A class used to find the admins for an assembly.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(assembly) ⇒ AdminUsers

Initializes the class.

assembly - an assembly that needs to find its assembly admins


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

def initialize(assembly)
  @assembly = assembly
end

Class Method Details

.for(assembly) ⇒ Object

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

assembly - an assembly that needs to find its assembly admins


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

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

Instance Method Details

#queryObject

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

Returns an ActiveRecord::Relation.


25
26
27
# File 'decidim-assemblies/app/queries/decidim/assemblies/admin/admin_users.rb', line 25

def query
  Decidim::User.where(id: organization_admins).or(assembly_user_admins)
end