Class: Decidim::NavigationMaps::SaveArea

Inherits:
Rectify::Command
  • Object
show all
Defined in:
app/commands/decidim/navigation_maps/save_area.rb

Overview

This command creates or updates areas for a blueprints

Instance Method Summary collapse

Constructor Details

#initialize(form) ⇒ SaveArea

Creates or updates an area for a blueprint.

form - The form with the data.



10
11
12
# File 'app/commands/decidim/navigation_maps/save_area.rb', line 10

def initialize(form)
  @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.



20
21
22
23
24
25
26
27
28
# File 'app/commands/decidim/navigation_maps/save_area.rb', line 20

def call
  return broadcast(:invalid, form.errors.full_messages.join(", ")) if form.invalid?

  initialize_area
  update_area
  save_area!

  broadcast(:ok, @area)
end