Class: Decidim::Admin::UpdateHelpSections
- Defined in:
- decidim-admin/app/commands/decidim/admin/update_help_sections.rb
Overview
This command gets called when a content block is updated from the admin panel.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(form, organization, user) ⇒ UpdateHelpSections
constructor
A new instance of UpdateHelpSections.
Methods inherited from Command
call, #evaluate, #method_missing, #respond_to_missing?, #transaction, #with_events
Constructor Details
#initialize(form, organization, user) ⇒ UpdateHelpSections
Returns a new instance of UpdateHelpSections.
8 9 10 11 12 |
# File 'decidim-admin/app/commands/decidim/admin/update_help_sections.rb', line 8 def initialize(form, organization, user) @form = form @organization = organization @user = user end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Decidim::Command
Instance Method Details
#call ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'decidim-admin/app/commands/decidim/admin/update_help_sections.rb', line 14 def call return broadcast(:invalid) unless @form.valid? ActiveRecord::Base.transaction do @form.sections.each do |section| next unless content_has_changed?(section) Decidim.traceability.perform_action!("update", ContextualHelpSection, @user, { "resource" => { "title" => section.id.humanize } }) do ContextualHelpSection.set_content(@organization, section.id, section.content) ContextualHelpSection.find_by(organization: @organization, section_id: section.id) end end end broadcast(:ok) end |