Sha256: 1573b3036f1c982c11ebf9ca2aff63d0dbb27fb52b2fab9bd91094473cdaaab4
Contents?: true
Size: 1.08 KB
Versions: 50
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
50 entries across 50 versions & 2 rubygems