Sha256: af6a661907ed820b33f81ddd4a1fc2b17522cb2d759fb19c67b1c23ab8292f92
Contents?: true
Size: 1.08 KB
Versions: 13
Compression:
Stored size: 1.08 KB
Contents
# frozen_string_literal: true module Decidim module Proposals module Admin # A command with all the business logic when an admin answers a proposal. class AnswerProposal < Rectify::Command # Public: Initializes the command. # # form - A form object with the params. # proposal - The proposal to write the answer for. def initialize(form, proposal) @form = form @proposal = proposal end # Executes the command. Broadcasts these events: # # - :ok when everything is valid. # - :invalid if the form wasn't valid and we couldn't proceed. # # Returns nothing. def call return broadcast(:invalid) if form.invalid? answer_proposal broadcast(:ok) end private attr_reader :form, :proposal def answer_proposal proposal.update_attributes!( state: @form.state, answer: @form.answer, answered_at: Time.current ) end end end end end
Version data entries
13 entries across 13 versions & 2 rubygems