Class: Decidim::Challenges::Admin::UpdateChallenge
- Inherits:
-
Decidim::Command
- Object
- Decidim::Command
- Decidim::Challenges::Admin::UpdateChallenge
- Includes:
- AttachmentAttributesMethods
- Defined in:
- app/commands/decidim/challenges/admin/update_challenge.rb
Overview
A command with all the business logic when a user updates a challenge.
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(form, challenge) ⇒ UpdateChallenge
constructor
Public: Initializes the command.
Constructor Details
#initialize(form, challenge) ⇒ UpdateChallenge
Public: Initializes the command.
form - A form object with the params. challenge - the challenge to update.
14 15 16 17 18 |
# File 'app/commands/decidim/challenges/admin/update_challenge.rb', line 14 def initialize(form, challenge) super() @form = form @challenge = challenge end |
Instance Method Details
#call ⇒ Object
Executes the command. Broadcasts these events:
-
:ok when everything is valid, together with the challenge.
-
:invalid if the form wasn’t valid and we couldn’t proceed.
Returns nothing.
26 27 28 29 30 31 32 33 34 |
# File 'app/commands/decidim/challenges/admin/update_challenge.rb', line 26 def call return broadcast(:invalid) if form.invalid? transaction do update_challenge end broadcast(:ok, challenge) end |