Class: Decidim::ParticipatoryDocuments::Admin::UpdateSection
- Inherits:
-
Command
- Object
- Command
- Decidim::ParticipatoryDocuments::Admin::UpdateSection
- Defined in:
- app/commands/decidim/participatory_documents/admin/update_section.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(form, document) ⇒ UpdateSection
constructor
Public: Initializes the command.
Constructor Details
#initialize(form, document) ⇒ UpdateSection
Public: Initializes the command.
form - A form object with the params.
10 11 12 13 |
# File 'app/commands/decidim/participatory_documents/admin/update_section.rb', line 10 def initialize(form, document) @form = form @document = document end |
Instance Method Details
#call ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/commands/decidim/participatory_documents/admin/update_section.rb', line 15 def call return broadcast(:invalid) if form.invalid? begin transaction do update_section end broadcast(:ok, section) rescue ActiveRecord::RecordInvalid broadcast(:invalid) end end |