Class: Decidim::UserGroups::AcceptedUsers
- Defined in:
 - app/queries/decidim/user_groups/accepted_users.rb
 
Overview
Use this class to find the accepted members of the given user group.
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)  ⇒ AcceptedUsers 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
Initializes the class.
 - 
  
    
      #query  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Finds the accepted members of the user group.
 
Methods inherited from Query
#cached_query, #each, #eager?, #exists?, merge, #none?, #relation?, #|
Constructor Details
#initialize(user_group) ⇒ AcceptedUsers
Initializes the class.
user_group - a UserGroup that needs to find its accepted members
      17 18 19  | 
    
      # File 'app/queries/decidim/user_groups/accepted_users.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 members
      10 11 12  | 
    
      # File 'app/queries/decidim/user_groups/accepted_users.rb', line 10 def self.for(user_group) new(user_group).query end  | 
  
Instance Method Details
#query ⇒ Object
Finds the accepted members of the user group.
Returns an ActiveRecord::Relation.
      24 25 26 27 28 29  | 
    
      # File 'app/queries/decidim/user_groups/accepted_users.rb', line 24 def query user_group .users .includes(:memberships) .where(decidim_user_group_memberships: { role: %w(creator admin member) }) end  |