Class: Decidim::Assemblies::Admin::UpdateAssembliesSetting

Inherits:
Rectify::Command
  • Object
show all
Defined in:
decidim-assemblies/app/commands/decidim/assemblies/admin/update_assemblies_setting.rb

Overview

A command with all the business logic when updating assemblies settings in admin area.

Instance Method Summary collapse

Constructor Details

#initialize(assemblies_settings, form) ⇒ UpdateAssembliesSetting

Public: Initializes the command.

assemblies_setting - A assemblies_setting object to update. form - A form object with the params.


13
14
15
16
# File 'decidim-assemblies/app/commands/decidim/assemblies/admin/update_assemblies_setting.rb', line 13

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

Instance Method Details

#callObject

Executes the command. Broadcasts these events:

  • :ok when everything is valid.

  • :invalid if the form or assemblies_settings isn't valid and we couldn't proceed.

Returns nothing.


24
25
26
27
28
29
30
# File 'decidim-assemblies/app/commands/decidim/assemblies/admin/update_assemblies_setting.rb', line 24

def call
  return broadcast(:invalid) if form.invalid? || assemblies_settings.invalid?

  update_assemblies_setting!

  broadcast(:ok)
end