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