Class: Decidim::Proposals::Admin::AnswerProposal
- Defined in:
- decidim-proposals/app/commands/decidim/proposals/admin/answer_proposal.rb
Overview
A command with all the business logic when an admin answers a proposal.
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(form, proposal) ⇒ AnswerProposal
constructor
Public: Initializes the command.
Methods inherited from Command
call, #evaluate, #method_missing, #respond_to_missing?, #transaction, #with_events
Constructor Details
#initialize(form, proposal) ⇒ AnswerProposal
Public: Initializes the command.
form - A form object with the params. proposal - The proposal to write the answer for.
12 13 14 15 |
# File 'decidim-proposals/app/commands/decidim/proposals/admin/answer_proposal.rb', line 12 def initialize(form, proposal) @form = form @proposal = proposal end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Decidim::Command
Instance Method Details
#call ⇒ Object
Executes the command. Broadcasts these events:
-
:ok when everything is valid.
-
:invalid if the form was not valid and we could not proceed.
Returns nothing.
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'decidim-proposals/app/commands/decidim/proposals/admin/answer_proposal.rb', line 23 def call return broadcast(:invalid) if form.invalid? store_initial_proposal_state transaction do answer_proposal notify_proposal_answer end broadcast(:ok) end |