libertarian-party/partynest

View on GitHub
app/interactors/merge_contact_lists.rb

Summary

Maintainability
A
0 mins
Test Coverage
# frozen_string_literal: true

class MergeContactLists
  include Interactor

  after do
    context.old_contact_list.contacts.reload
    context.new_contact_list.contacts.reload
  end

  def call
    ActiveRecord::Base.transaction do
      context.old_contact_list.contacts.each do |contact|
        contact.update! contact_list: context.new_contact_list
      end
    end
  end
end