Sha256: 55c28017a8fe84870545ac419bc605750633e640b90837569c36668a66da6521
Contents?: true
Size: 1.18 KB
Versions: 7
Compression:
Stored size: 1.18 KB
Contents
# frozen_string_literal: true module Decidim module Initiatives module Admin # A command with all the business logic that updates an # existing initiative type scope. class UpdateInitiativeTypeScope < Decidim::Command # Public: Initializes the command. # # initiative_type: Decidim::InitiativesTypeScope # form - A form object with the params. def initialize(initiative_type_scope, form) @form = form @initiative_type_scope = initiative_type_scope 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? initiative_type_scope.update(attributes) broadcast(:ok, initiative_type_scope) end private attr_reader :form, :initiative_type_scope def attributes { supports_required: form.supports_required, decidim_scopes_id: form.decidim_scopes_id } end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems