You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: usergroup_member.rb
    path of file: ./repos/foreman/app/models
    
    the code of the file until where you have to start completion: class UsergroupMember < ApplicationRecord
  # the belongs to would apply default scope limiting the search by taxonomies but we need to delete
  # all members, regar
    
  def find_all_affected_memberships_for(member, direction = :usergroups)
    if member.is_a?(User)
      [member.usergroup_member]
    elsif member.is_a?(Usergroup)
      [member.usergroup_members.user_memberships +
           member.send(direction).map { |g| find_all_affected_memberships_for(g, direction) }]
    else
      raise ArgumentError, "Unknown member type #{member}"
    end