Class: Decidim::Surveys::AnswerSurvey
- Inherits:
-
Rectify::Command
- Object
- Rectify::Command
- Decidim::Surveys::AnswerSurvey
- Defined in:
- decidim-surveys/app/commands/decidim/surveys/answer_survey.rb
Overview
This command is executed when the user answers a Survey.
Instance Method Summary collapse
-
#call ⇒ Object
Answers a survey if it is valid.
-
#initialize(form, current_user, survey) ⇒ AnswerSurvey
constructor
Initializes a AnswerSurvey Command.
Constructor Details
#initialize(form, current_user, survey) ⇒ AnswerSurvey
Initializes a AnswerSurvey Command.
form - The form from which to get the data. survey - The current instance of the survey to be answered.
11 12 13 14 15 |
# File 'decidim-surveys/app/commands/decidim/surveys/answer_survey.rb', line 11 def initialize(form, current_user, survey) @form = form @current_user = current_user @survey = survey end |
Instance Method Details
#call ⇒ Object
Answers a survey if it is valid
Broadcasts :ok if successful, :invalid otherwise.
20 21 22 23 24 25 |
# File 'decidim-surveys/app/commands/decidim/surveys/answer_survey.rb', line 20 def call return broadcast(:invalid) if @form.invalid? answer_survey broadcast(:ok) end |