Class: Decidim::Proposals::Admin::AnswerProposal
- Inherits:
-
Rectify::Command
- Object
- Rectify::Command
- 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.
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.
11 12 13 14 |
# File 'decidim-proposals/app/commands/decidim/proposals/admin/answer_proposal.rb', line 11 def initialize(form, proposal) @form = form @proposal = proposal end |
Instance Method Details
#call ⇒ Object
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.
22 23 24 25 26 27 |
# File 'decidim-proposals/app/commands/decidim/proposals/admin/answer_proposal.rb', line 22 def call return broadcast(:invalid) if form.invalid? answer_proposal broadcast(:ok) end |