email_domain_block_batch.rb 626 B

123456789101112131415161718192021222324252627282930
  1. # frozen_string_literal: true
  2. class Form::EmailDomainBlockBatch
  3. include ActiveModel::Model
  4. include Authorization
  5. include AccountableConcern
  6. attr_accessor :email_domain_block_ids, :action, :current_account
  7. def save
  8. case action
  9. when 'delete'
  10. delete!
  11. end
  12. end
  13. private
  14. def email_domain_blocks
  15. @email_domain_blocks ||= EmailDomainBlock.where(id: email_domain_block_ids)
  16. end
  17. def delete!
  18. email_domain_blocks.each do |email_domain_block|
  19. authorize(email_domain_block, :destroy?)
  20. email_domain_block.destroy!
  21. log_action :destroy, email_domain_block
  22. end
  23. end
  24. end