Class: Decidim::Geo::Admin::UpdateGeoConfig

Inherits:
Command
  • Object
show all
Defined in:
app/commands/decidim/geo/admin/update_geo_config.rb

Overview

A command with all the business logic when updating a geo_config.

Instance Method Summary collapse

Constructor Details

#initialize(geo_config, form) ⇒ UpdateGeoConfig

Public: Initializes the command.

geo_config - The geo_config to update form - A form object with the params.



12
13
14
15
# File 'app/commands/decidim/geo/admin/update_geo_config.rb', line 12

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

Instance Method Details

#callObject

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.



23
24
25
26
27
# File 'app/commands/decidim/geo/admin/update_geo_config.rb', line 23

def call
  return broadcast(:invalid) if form.invalid?
  @geo_config.nil? ? create_geo_config : update_geo_config
  broadcast(:ok)
end