Sha256: dde8875fc313c8c7243e2326c8e137862892c27583e130b11c1ab75f34aabe65
Contents?: true
Size: 1.06 KB
Versions: 7
Compression:
Stored size: 1.06 KB
Contents
# frozen_string_literal: true module Decidim module Admin # A command with all the business logic when updating an area type. class UpdateAreaType < Decidim::Command # Public: Initializes the command. # # area_type - The AreaType to update # form - A form object with the params. def initialize(area_type, form, user) @area_type = area_type @form = form @user = user end # Executes the command. Broadcasts these events: # # - :ok when everything is valid. # - :invalid if the form was not valid and we could not proceed. # # Returns nothing. def call return broadcast(:invalid) if form.invalid? update_area_type broadcast(:ok) end private attr_reader :form def update_area_type Decidim.traceability.update!( @area_type, @user, attributes ) end def attributes { name: form.name, plural: form.plural } end end end end
Version data entries
7 entries across 7 versions & 1 rubygems