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

Inherits:
Command
  • Object
show all
Defined in:
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

Constructor Details

#initialize(question, current_user) ⇒ UpdateQuestionStatus

Initializes a UpdateQuestionnaire Command.

questionnaire - The current instance of the questionnaire to be updated. current_user - The current user.



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

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

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 '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