Sha256: b42ccba6f77259b7ac60f587f1635588bf7e6472af166cf0631f416fd23dc6a0
Contents?: true
Size: 949 Bytes
Versions: 2
Compression:
Stored size: 949 Bytes
Contents
# frozen_string_literal: true module Decidim module Admin # A command with all the business logic when updating an area. class UpdateArea < Rectify::Command # Public: Initializes the command. # # area - The Area to update # form - A form object with the params. def initialize(area, form) @area = area @form = form end # 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. def call return broadcast(:invalid) if form.invalid? update_area broadcast(:ok) end private attr_reader :form def update_area @area.update!(attributes) end def attributes { name: form.name, area_type: form.area_type } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
decidim-admin-0.10.1 | app/commands/decidim/admin/update_area.rb |
decidim-admin-0.10.0 | app/commands/decidim/admin/update_area.rb |