Class: Decidim::Challenges::Admin::UpdateSurveys
- Inherits:
-
Decidim::Command
- Object
- Decidim::Command
- Decidim::Challenges::Admin::UpdateSurveys
- Defined in:
- app/commands/decidim/challenges/admin/update_surveys.rb
Overview
This command is executed when the user updates the challenge survey,
Instance Method Summary collapse
-
#call ⇒ Object
Updates the challenge if valid.
-
#initialize(form, challenge) ⇒ UpdateSurveys
constructor
Initializes a UpdateSurveys Command.
Constructor Details
#initialize(form, challenge) ⇒ UpdateSurveys
Initializes a UpdateSurveys Command.
form - The form from which to get the data. challenge - The current instance of the challenge to be updated.
12 13 14 15 16 |
# File 'app/commands/decidim/challenges/admin/update_surveys.rb', line 12 def initialize(form, challenge) super() @form = form @challenge = challenge end |
Instance Method Details
#call ⇒ Object
Updates the challenge if valid.
Broadcasts :ok if successful, :invalid otherwise.
21 22 23 24 25 26 27 28 29 |
# File 'app/commands/decidim/challenges/admin/update_surveys.rb', line 21 def call return broadcast(:invalid) if form.invalid? challenge.with_lock do update_challenge_surveys end broadcast(:ok) end |