gitlab-org--gitlab-foss/app/services/members/standard_member_builder.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

24 lines
573 B
Ruby
Raw Normal View History

# frozen_string_literal: true
module Members
class StandardMemberBuilder
def initialize(source, invitee, existing_members)
@source = source
@invitee = invitee
@existing_members = existing_members
end
def execute
find_or_initialize_member_by_user(invitee.id)
end
private
attr_reader :source, :invitee, :existing_members
def find_or_initialize_member_by_user(user_id)
existing_members[user_id] || source.members_and_requesters.build(user_id: user_id) # rubocop:disable CodeReuse/ActiveRecord
end
end
end