Class: Decidim::UserGroups::InvitedMemberships
- Defined in:
- app/queries/decidim/user_groups/invited_memberships.rb
Overview
Use this class to find the invitations to user groups the given user has.
Class Method Summary collapse
-
.for(user) ⇒ Object
Syntactic sugar to initialize the class and return the queried objects.
Instance Method Summary collapse
-
#initialize(user) ⇒ InvitedMemberships
constructor
Initializes the class.
-
#query ⇒ Object
Finds the UserGroupMemberships the user has been invited to.
Methods inherited from Query
#cached_query, #each, #eager?, #exists?, merge, #none?, #relation?, #|
Constructor Details
#initialize(user) ⇒ InvitedMemberships
Initializes the class.
user - a User that needs to find which groups they have been invited to
17 18 19 |
# File 'app/queries/decidim/user_groups/invited_memberships.rb', line 17 def initialize(user) @user = user end |
Class Method Details
.for(user) ⇒ Object
Syntactic sugar to initialize the class and return the queried objects.
user - a User that needs to find which groups they have been invited to
10 11 12 |
# File 'app/queries/decidim/user_groups/invited_memberships.rb', line 10 def self.for(user) new(user).query end |
Instance Method Details
#query ⇒ Object
Finds the UserGroupMemberships the user has been invited to.
Returns an ActiveRecord::Relation.
24 25 26 27 28 29 |
# File 'app/queries/decidim/user_groups/invited_memberships.rb', line 24 def query user .memberships .includes(:user_group) .where(role: "invited") end |