Class: Decidim::Geo::Admin::UpdateGeoConfig
- 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
-
#call ⇒ Object
Executes the command.
-
#initialize(geo_config, form) ⇒ UpdateGeoConfig
constructor
Public: Initializes the command.
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
#call ⇒ Object
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 |