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.23.6 app/queries/decidim/user_groups/invited_memberships.rb
decidim-core-0.24.2 app/queries/decidim/user_groups/invited_memberships.rb
decidim-core-0.23.5 app/queries/decidim/user_groups/invited_memberships.rb
decidim-core-0.24.1 app/queries/decidim/user_groups/invited_memberships.rb
decidim-core-0.24.0 app/queries/decidim/user_groups/invited_memberships.rb
decidim-core-0.24.0.rc2 app/queries/decidim/user_groups/invited_memberships.rb
decidim-core-0.23.4 app/queries/decidim/user_groups/invited_memberships.rb
decidim-core-0.24.0.rc1 app/queries/decidim/user_groups/invited_memberships.rb
decidim-core-0.23.3 app/queries/decidim/user_groups/invited_memberships.rb
decidim-core-0.23.2 app/queries/decidim/user_groups/invited_memberships.rb
decidim-core-0.23.1 app/queries/decidim/user_groups/invited_memberships.rb
decidim-core-0.23.1.rc1 app/queries/decidim/user_groups/invited_memberships.rb
decidim-core-0.23.0 app/queries/decidim/user_groups/invited_memberships.rb
decidim-core-0.22.0 app/queries/decidim/user_groups/invited_memberships.rb
decidim-core-0.21.0 app/queries/decidim/user_groups/invited_memberships.rb
decidim-core-0.20.1 app/queries/decidim/user_groups/invited_memberships.rb
decidim-core-0.20.0 app/queries/decidim/user_groups/invited_memberships.rb
decidim-core-0.19.1 app/queries/decidim/user_groups/invited_memberships.rb
decidim-core-0.18.1 app/queries/decidim/user_groups/invited_memberships.rb
decidim-core-0.19.0 app/queries/decidim/user_groups/invited_memberships.rb