Class: Decidim::Meetings::Admin::UpdateQuestionnaire
- Inherits:
-
Command
- Object
- Command
- Decidim::Meetings::Admin::UpdateQuestionnaire
- Defined in:
- app/commands/decidim/meetings/admin/update_questionnaire.rb
Overview
This command is executed when the user changes a Questionnaire from the admin panel.
Instance Method Summary collapse
-
#call ⇒ Object
Updates the questionnaire if valid.
-
#initialize(form, questionnaire) ⇒ UpdateQuestionnaire
constructor
Initializes a UpdateQuestionnaire Command.
Constructor Details
#initialize(form, questionnaire) ⇒ UpdateQuestionnaire
Initializes a UpdateQuestionnaire Command.
form - The form from which to get the data. questionnaire - The current instance of the questionnaire to be updated.
13 14 15 16 |
# File 'app/commands/decidim/meetings/admin/update_questionnaire.rb', line 13 def initialize(form, questionnaire) @form = form @questionnaire = questionnaire end |
Instance Method Details
#call ⇒ Object
Updates the questionnaire if valid.
Broadcasts :ok if successful, :invalid otherwise.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/commands/decidim/meetings/admin/update_questionnaire.rb', line 21 def call return broadcast(:invalid) if @form.invalid? Decidim.traceability.perform_action!("update", Decidim::Meetings::Questionnaire, @form.current_user, { meeting: @questionnaire.questionnaire_for.try(:meeting) }) do Decidim::Meetings::Questionnaire.transaction do create_questionnaire_for create_questionnaire update_questionnaire_questions @questionnaire end end broadcast(:ok) end |