Sha256: 1ec9c89d7a44da8f81da9e1282ec0e3f064b41c11606b6248099bbefde2e33fc

Contents?: true

Size: 905 Bytes

Versions: 49

Compression:

Stored size: 905 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module UserGroups
    # Use this class to find the invitations to user groups the given user has.
    class InvitedMemberships < Rectify::Query
      # 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
      def self.for(user)
        new(user).query
      end

      # Initializes the class.
      #
      # user - a User that needs to find which groups they have been invited to
      def initialize(user)
        @user = user
      end

      # Finds the UserGroupMemberships the user has been invited to.
      #
      # Returns an ActiveRecord::Relation.
      def query
        user
          .memberships
          .includes(:user_group)
          .where(role: "invited")
      end

      private

      attr_reader :user
    end
  end
end

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
decidim-core-0.26.10 app/queries/decidim/user_groups/invited_memberships.rb
decidim-core-0.26.9 app/queries/decidim/user_groups/invited_memberships.rb
decidim-core-0.26.8 app/queries/decidim/user_groups/invited_memberships.rb
decidim-core-0.26.7 app/queries/decidim/user_groups/invited_memberships.rb
decidim-core-0.26.5 app/queries/decidim/user_groups/invited_memberships.rb
decidim-core-0.26.4 app/queries/decidim/user_groups/invited_memberships.rb
decidim-core-0.26.3 app/queries/decidim/user_groups/invited_memberships.rb
decidim-core-0.26.2 app/queries/decidim/user_groups/invited_memberships.rb
decidim-core-0.26.1 app/queries/decidim/user_groups/invited_memberships.rb
decidim-core-0.26.0 app/queries/decidim/user_groups/invited_memberships.rb
decidim-core-0.26.0.rc2 app/queries/decidim/user_groups/invited_memberships.rb
decidim-core-0.26.0.rc1 app/queries/decidim/user_groups/invited_memberships.rb
decidim-core-0.25.2 app/queries/decidim/user_groups/invited_memberships.rb
decidim-core-0.25.1 app/queries/decidim/user_groups/invited_memberships.rb
decidim-core-0.25.0 app/queries/decidim/user_groups/invited_memberships.rb
decidim-core-0.25.0.rc4 app/queries/decidim/user_groups/invited_memberships.rb
decidim-core-0.25.0.rc3 app/queries/decidim/user_groups/invited_memberships.rb
decidim-core-0.25.0.rc2 app/queries/decidim/user_groups/invited_memberships.rb
decidim-core-0.25.0.rc1 app/queries/decidim/user_groups/invited_memberships.rb
decidim-core-0.24.3 app/queries/decidim/user_groups/invited_memberships.rb