Class: Decidim::Problems::Admin::UpdateProblem
- Inherits:
-
Command
- Object
- Command
- Decidim::Problems::Admin::UpdateProblem
- Defined in:
- app/commands/decidim/problems/admin/update_problem.rb
Overview
A command with all the business logic when a user updates a Problem.
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(form, problem) ⇒ UpdateProblem
constructor
Public: Initializes the command.
Constructor Details
#initialize(form, problem) ⇒ UpdateProblem
Public: Initializes the command.
form - A form object with the params. problem - the problem to update.
12 13 14 15 16 |
# File 'app/commands/decidim/problems/admin/update_problem.rb', line 12 def initialize(form, problem) super() @form = form @problem = problem 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.
24 25 26 27 28 29 30 31 32 |
# File 'app/commands/decidim/problems/admin/update_problem.rb', line 24 def call return broadcast(:invalid) if form.invalid? transaction do update_problem end broadcast(:ok, problem) end |