Class: Decidim::Admin::UpdateCategory
- Inherits:
-
Rectify::Command
- Object
- Rectify::Command
- Decidim::Admin::UpdateCategory
- Defined in:
- app/commands/decidim/admin/update_category.rb
Overview
A command with all the business logic when updating a category in the system.
Instance Attribute Summary collapse
-
#category ⇒ Object
readonly
Returns the value of attribute category.
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(category, form) ⇒ UpdateCategory
constructor
Public: Initializes the command.
Constructor Details
#initialize(category, form) ⇒ UpdateCategory
Public: Initializes the command.
category - the Category to update form - A form object with the params.
14 15 16 17 |
# File 'app/commands/decidim/admin/update_category.rb', line 14 def initialize(category, form) @category = category @form = form end |
Instance Attribute Details
#category ⇒ Object (readonly)
Returns the value of attribute category.
8 9 10 |
# File 'app/commands/decidim/admin/update_category.rb', line 8 def category @category end |
Instance Method Details
#call ⇒ Object
Executes the command. Broadcasts these events:
-
:ok when everything is valid.
-
:invalid if the form wasn’t valid and we couldn’t proceed.
Returns nothing.
25 26 27 28 29 30 |
# File 'app/commands/decidim/admin/update_category.rb', line 25 def call return broadcast(:invalid) if form.invalid? update_category broadcast(:ok) end |