Class: Decidim::UserGroups::AdminMemberships
- Defined in:
- app/queries/decidim/user_groups/admin_memberships.rb
Overview
Use this class to find the the admins of the given user group with the “admin” role. It returns memberships.
Class Method Summary collapse
-
.for(user_group) ⇒ Object
Syntactic sugar to initialize the class and return the queried objects.
Instance Method Summary collapse
-
#initialize(user_group) ⇒ AdminMemberships
constructor
Initializes the class.
-
#query ⇒ Object
Finds the admin users of the user group.
Methods inherited from Query
#cached_query, #each, #eager?, #exists?, merge, #none?, #relation?, #|
Constructor Details
#initialize(user_group) ⇒ AdminMemberships
Initializes the class.
user_group - a UserGroup that needs to find its admin users
18 19 20 |
# File 'app/queries/decidim/user_groups/admin_memberships.rb', line 18 def initialize(user_group) @user_group = user_group end |
Class Method Details
.for(user_group) ⇒ Object
Syntactic sugar to initialize the class and return the queried objects.
user_group - a UserGroup that needs to find its admin users
11 12 13 |
# File 'app/queries/decidim/user_groups/admin_memberships.rb', line 11 def self.for(user_group) new(user_group).query end |
Instance Method Details
#query ⇒ Object
Finds the admin users of the user group.
Returns an ActiveRecord::Relation.
25 26 27 28 29 30 |
# File 'app/queries/decidim/user_groups/admin_memberships.rb', line 25 def query user_group .non_deleted_memberships .includes(:user) .where(role: :admin) end |