Class: Decidim::Admin::UpdateHelpSections

Inherits:
Command
  • Object
show all
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

Methods inherited from Command

call, #evaluate, #method_missing, #respond_to_missing?, #transaction

Constructor Details

#initialize(form, organization) ⇒ UpdateHelpSections

Returns a new instance of UpdateHelpSections.


8
9
10
11
# File 'decidim-admin/app/commands/decidim/admin/update_help_sections.rb', line 8

def initialize(form, organization)
  @form = form
  @organization = organization
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Decidim::Command

Instance Method Details

#callObject


13
14
15
16
17
18
19
20
21
22
23
# File 'decidim-admin/app/commands/decidim/admin/update_help_sections.rb', line 13

def call
  return broadcast(:invalid) unless @form.valid?

  ActiveRecord::Base.transaction do
    @form.sections.each do |section|
      ContextualHelpSection.set_content(@organization, section.id, section.content)
    end
  end

  broadcast(:ok)
end