Class: Decidim::Consultations::Admin::UpdateQuestionConfiguration
- Inherits:
-
Decidim::Command
- Object
- Decidim::Command
- Decidim::Consultations::Admin::UpdateQuestionConfiguration
- Defined in:
- app/commands/decidim/consultations/admin/update_question_configuration.rb
Overview
A command that configures how many and how much questions can be voted.
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(question, form) ⇒ UpdateQuestionConfiguration
constructor
Public: Initializes the command.
Constructor Details
#initialize(question, form) ⇒ UpdateQuestionConfiguration
Public: Initializes the command.
question - the Question to update form - A form object with the params.
12 13 14 15 |
# File 'app/commands/decidim/consultations/admin/update_question_configuration.rb', line 12 def initialize(question, form) @question = question @form = form 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.
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/commands/decidim/consultations/admin/update_question_configuration.rb', line 23 def call return broadcast(:invalid) if form.invalid? # We don't have other question fields in this forms so any additional # validation error will be just shown in a flash message begin update_question! broadcast(:ok, question) rescue StandardError => e broadcast(:invalid, question, e.) end end |