Class: Decidim::Surveys::UnpublishResponses

Inherits:
Command
  • Object
show all
Includes:
TranslatableAttributes
Defined in:
app/commands/decidim/surveys/unpublish_responses.rb

Overview

This command is executed when the admin unpublishes the Responses from the admin panel.

Instance Method Summary collapse

Constructor Details

#initialize(question_id, current_user) ⇒ UnpublishResponses

Initializes a UnpublishResponses Command.



12
13
14
15
# File 'app/commands/decidim/surveys/unpublish_responses.rb', line 12

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

Instance Method Details

#callObject

Unpublishes the questions’ responses

Broadcasts :ok if successful, :invalid otherwise.



20
21
22
23
24
25
26
27
28
29
# File 'app/commands/decidim/surveys/unpublish_responses.rb', line 20

def call
  transaction do
    unpublish_survey_response
    create_action_log
  end

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