Sha256: b077406fff84a8d68ec53ec3d57a176fd2964ce2ab9433df9cff1b9130a39188
Contents?: true
Size: 1.18 KB
Versions: 12
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 wasn't valid and we couldn't 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
12 entries across 12 versions & 1 rubygems