Class: Decidim::Meetings::Admin::UpdateQuestionStatus

Inherits:
Command
  • Object
show all
Defined in:
decidim-meetings/app/commands/decidim/meetings/admin/update_question_status.rb

Overview

This command is executed when the user changes a Questionnaire from the admin panel.

Defined Under Namespace

Classes: InvalidStatus

Instance Method Summary collapse

Methods inherited from Command

call, #evaluate, #method_missing, #respond_to_missing?, #transaction, #with_events

Constructor Details

#initialize(question, current_user) ⇒ UpdateQuestionStatus

Initializes a UpdateQuestionnaire Command.

form - The form from which to get the data. questionnaire - The current instance of the questionnaire to be updated.



15
16
17
18
# File 'decidim-meetings/app/commands/decidim/meetings/admin/update_question_status.rb', line 15

def initialize(question, current_user)
  @question = question
  @current_user = current_user
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Decidim::Command

Instance Method Details

#callObject

Updates the questionnaire if valid.

Broadcasts :ok if successful, :invalid otherwise.



23
24
25
26
27
28
29
30
31
# File 'decidim-meetings/app/commands/decidim/meetings/admin/update_question_status.rb', line 23

def call
  Decidim::Meetings::Question.transaction do
    update_question
  end

  broadcast(:ok)
rescue InvalidStatus
  broadcast(:invalid)
end