houdini/lib/delete/delete_campaign_gift_option.rb

18 lines
610 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2020-06-12 20:03:43 +00:00
# License: AGPL-3.0-or-later WITH WTO-AP-3.0-or-later
# Full license explanation at https://github.com/houdiniproject/houdini/blob/master/LICENSE
module DeleteCampaignGiftOption
def self.delete(campaign_gift_option)
CampaignGiftOption.transaction do
if campaign_gift_option.campaign_gifts.any?
raise ParamValidation::ValidationError.new("#{campaign_gift_option&.id} already has campaign gifts. It can't be deleted for safety reasons.", key: :campaign_gift_option_id)
end
campaign_gift_option.destroy
campaign_gift_option
end
end
end