Sha256: 788206b2927925bdc3071939c45b0d071fdf48c3e3054232bd5febf290cfe079
Contents?: true
Size: 750 Bytes
Versions: 13
Compression:
Stored size: 750 Bytes
Contents
# frozen_string_literal: true module Decidim module Surveys class CleanSurveyAnswersJob < ApplicationJob def perform(_event_name, data) @component = data[:resource] return unless component&.manifest_name == "surveys" @survey = Survey.find_by(component:) return unless survey&.questionnaire case data[:event_class] when "Decidim::ComponentPublishedEvent" clean_answers end end private attr_reader :survey, :component def clean_answers return unless survey.clean_after_publish? survey.questionnaire.answers.destroy_all component.settings[:clean_after_publish] = false component.save end end end end
Version data entries
13 entries across 13 versions & 1 rubygems