Class: Decidim::Surveys::Admin::UpdateSurveySettings
- Inherits:
-
Forms::Admin::UpdateQuestionnaire
- Object
- Command
- Forms::Admin::UpdateQuestionnaire
- Decidim::Surveys::Admin::UpdateSurveySettings
- Defined in:
- decidim-surveys/app/commands/decidim/surveys/admin/update_survey_settings.rb
Overview
This command is executed when the user changes a Survey Settings (also known as their attributes) from the admin panel.
Instance Attribute Summary collapse
-
#form ⇒ Object
readonly
Returns the value of attribute form.
-
#survey ⇒ Object
readonly
Returns the value of attribute survey.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
-
#call ⇒ Object
Updates the survey questionnaire if valid.
-
#initialize(form, survey, user) ⇒ UpdateSurveySettings
constructor
Initializes a UpdateSurveySettings Command.
Methods inherited from Command
call, #evaluate, #method_missing, #respond_to_missing?, #transaction, #with_events
Constructor Details
#initialize(form, survey, user) ⇒ UpdateSurveySettings
Initializes a UpdateSurveySettings Command.
form - The form from which to get the data. survey - The current instance of the survey to be updated. user - The user doing the update
14 15 16 17 18 |
# File 'decidim-surveys/app/commands/decidim/surveys/admin/update_survey_settings.rb', line 14 def initialize(form, survey, user) @form = form @survey = survey @user = user end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Decidim::Command
Instance Attribute Details
#form ⇒ Object (readonly)
Returns the value of attribute form.
20 21 22 |
# File 'decidim-surveys/app/commands/decidim/surveys/admin/update_survey_settings.rb', line 20 def form @form end |
#survey ⇒ Object (readonly)
Returns the value of attribute survey.
20 21 22 |
# File 'decidim-surveys/app/commands/decidim/surveys/admin/update_survey_settings.rb', line 20 def survey @survey end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
20 21 22 |
# File 'decidim-surveys/app/commands/decidim/surveys/admin/update_survey_settings.rb', line 20 def user @user end |
Instance Method Details
#call ⇒ Object
Updates the survey questionnaire if valid.
Broadcasts :ok if successful, :invalid otherwise.
25 26 27 28 29 30 31 32 33 34 35 |
# File 'decidim-surveys/app/commands/decidim/surveys/admin/update_survey_settings.rb', line 25 def call Decidim.traceability.perform_action!("update", survey, user) do transaction do update_survey_settings end rescue ActiveRecord::RecordInvalid broadcast(:invalid) end broadcast(:ok) end |