Sha256: baa594025649e80244f46061b264ec31eb1bb89dea96ca84e24b8e8e0658fe1c

Contents?: true

Size: 940 Bytes

Versions: 25

Compression:

Stored size: 940 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module UserGroups
    # Use this class to find the the members of the given user group with the
    # "member" role. It returns memberships.
    class MemberMemberships < Rectify::Query
      # Syntactic sugar to initialize the class and return the queried objects.
      #
      # user_group - a UserGroup that needs to find its member users
      def self.for(user_group)
        new(user_group).query
      end

      # Initializes the class.
      #
      # user_group - a UserGroup that needs to find its member users
      def initialize(user_group)
        @user_group = user_group
      end

      # Finds the member users of the user group.
      #
      # Returns an ActiveRecord::Relation.
      def query
        user_group
          .memberships
          .includes(:user)
          .where(role: :member)
      end

      private

      attr_reader :user_group
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
decidim-core-0.23.5 app/queries/decidim/user_groups/member_memberships.rb
decidim-core-0.24.0.rc2 app/queries/decidim/user_groups/member_memberships.rb
decidim-core-0.23.4 app/queries/decidim/user_groups/member_memberships.rb
decidim-core-0.24.0.rc1 app/queries/decidim/user_groups/member_memberships.rb
decidim-core-0.23.3 app/queries/decidim/user_groups/member_memberships.rb
decidim-core-0.23.2 app/queries/decidim/user_groups/member_memberships.rb
decidim-core-0.23.1 app/queries/decidim/user_groups/member_memberships.rb
decidim-core-0.23.1.rc1 app/queries/decidim/user_groups/member_memberships.rb
decidim-core-0.23.0 app/queries/decidim/user_groups/member_memberships.rb
decidim-core-0.22.0 app/queries/decidim/user_groups/member_memberships.rb
decidim-core-0.21.0 app/queries/decidim/user_groups/member_memberships.rb
decidim-core-0.20.1 app/queries/decidim/user_groups/member_memberships.rb
decidim-core-0.20.0 app/queries/decidim/user_groups/member_memberships.rb
decidim-core-0.19.1 app/queries/decidim/user_groups/member_memberships.rb
decidim-core-0.18.1 app/queries/decidim/user_groups/member_memberships.rb
decidim-core-0.19.0 app/queries/decidim/user_groups/member_memberships.rb
decidim-core-0.17.2 app/queries/decidim/user_groups/member_memberships.rb
decidim-core-0.18.0 app/queries/decidim/user_groups/member_memberships.rb
decidim-core-0.17.1 app/queries/decidim/user_groups/member_memberships.rb
decidim-core-0.16.1 app/queries/decidim/user_groups/member_memberships.rb