Class: Decidim::Proposals::Admin::ProposalAnswerJob

Inherits:
ApplicationJob
  • Object
show all
Defined in:
app/jobs/decidim/proposals/admin/proposal_answer_job.rb

Instance Method Summary collapse

Instance Method Details

#perform(proposal, attributes, context) ⇒ Object



9
10
11
12
13
14
15
16
# File 'app/jobs/decidim/proposals/admin/proposal_answer_job.rb', line 9

def perform(proposal, attributes, context)
  answer_form = ProposalAnswerForm.from_params(attributes).with_context(**context)

  Admin::AnswerProposal.call(answer_form, proposal) do
    on(:ok) { Rails.logger.info "Proposal #{proposal.id} answered successfully." }
    on(:invalid) { Rails.logger.error "Proposal ID #{proposal.id} could not be updated. Errors: #{answer_form.errors.full_messages}" }
  end
end