Class: Decidim::UserGroups::AcceptedMemberships

Inherits:
Rectify::Query
  • Object
show all
Defined in:
decidim-core/app/queries/decidim/user_groups/accepted_memberships.rb

Overview

Use this class to find the accepted memberships of the given user group.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user_group) ⇒ AcceptedMemberships

Initializes the class.

user_group - a UserGroup that needs to find its accepted memberships


17
18
19
# File 'decidim-core/app/queries/decidim/user_groups/accepted_memberships.rb', line 17

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 accepted memberships


10
11
12
# File 'decidim-core/app/queries/decidim/user_groups/accepted_memberships.rb', line 10

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

Instance Method Details

#queryObject

Finds the accepted memberships of the user group.

Returns an ActiveRecord::Relation.


24
25
26
27
28
29
# File 'decidim-core/app/queries/decidim/user_groups/accepted_memberships.rb', line 24

def query
  user_group
    .non_deleted_memberships
    .includes(:user)
    .where(role: %w(creator admin member))
end