Sha256: f65778d79b946e2607388b375feeab21d5d08291f5d6446fe00c4c46d933095e

Contents?: true

Size: 1.33 KB

Versions: 7

Compression:

Stored size: 1.33 KB

Contents

# frozen_string_literal: true

module Decidim
  module ParticipatoryProcesses
    module Admin
      # A command with all the business logic when updating a participatory
      # process type in the system.
      class UpdateParticipatoryProcessType < Decidim::Command
        # Public: Initializes the command.
        #
        # participatory_process_type - A participatory_process_type object to
        # update
        # form - A form object with the params.
        def initialize(participatory_process_type, form)
          @participatory_process_type = participatory_process_type
          @form = form
        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_participatory_process_type!

          broadcast(:ok)
        end

        private

        attr_reader :form, :participatory_process_type

        def update_participatory_process_type!
          transaction do
            Decidim.traceability.update!(
              participatory_process_type,
              form.current_user,
              title: form.title
            )
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
decidim-participatory_processes-0.28.4 app/commands/decidim/participatory_processes/admin/update_participatory_process_type.rb
decidim-participatory_processes-0.28.3 app/commands/decidim/participatory_processes/admin/update_participatory_process_type.rb
decidim-participatory_processes-0.28.2 app/commands/decidim/participatory_processes/admin/update_participatory_process_type.rb
decidim-participatory_processes-0.28.1 app/commands/decidim/participatory_processes/admin/update_participatory_process_type.rb
decidim-participatory_processes-0.28.0 app/commands/decidim/participatory_processes/admin/update_participatory_process_type.rb
decidim-participatory_processes-0.28.0.rc5 app/commands/decidim/participatory_processes/admin/update_participatory_process_type.rb
decidim-participatory_processes-0.28.0.rc4 app/commands/decidim/participatory_processes/admin/update_participatory_process_type.rb