Sha256: 272a5e0b51d3cd4040b90772d445a9c2117d973250642b99e26ee4d612f1da54

Contents?: true

Size: 1.4 KB

Versions: 32

Compression:

Stored size: 1.4 KB

Contents

# frozen_string_literal: true

module Decidim
  module ParticipatoryProcesses
    module Admin
      # A command with all the business logic when creating a new participatory
      # process in the system.
      class UpdateParticipatoryProcessStep < Rectify::Command
        attr_reader :participatory_process_step
        # Public: Initializes the command.
        #
        # participatory_process_step - the ParticipatoryProcessStep to update
        # form - A form object with the params.
        def initialize(participatory_process_step, form)
          @participatory_process_step = participatory_process_step
          @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_participatory_process_step
          broadcast(:ok)
        end

        private

        attr_reader :form

        def update_participatory_process_step
          participatory_process_step.update_attributes!(attributes)
        end

        def attributes
          {
            title: form.title,
            start_date: form.start_date,
            end_date: form.end_date,
            description: form.description
          }
        end
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 2 rubygems

Version Path
decidim-participatory_processes-0.9.3 app/commands/decidim/participatory_processes/admin/update_participatory_process_step.rb
decidim-participatory_processes-0.9.2 app/commands/decidim/participatory_processes/admin/update_participatory_process_step.rb
decidim-participatory_processes-0.9.1 app/commands/decidim/participatory_processes/admin/update_participatory_process_step.rb
decidim-participatory_processes-0.9.0 app/commands/decidim/participatory_processes/admin/update_participatory_process_step.rb
decidim-participatory_processes-0.8.4 app/commands/decidim/participatory_processes/admin/update_participatory_process_step.rb
decidim-participatory_processes-0.8.3 app/commands/decidim/participatory_processes/admin/update_participatory_process_step.rb
decidim-participatory_processes-0.8.2 app/commands/decidim/participatory_processes/admin/update_participatory_process_step.rb
decidim-participatory_processes-0.8.1 app/commands/decidim/participatory_processes/admin/update_participatory_process_step.rb
decidim-participatory_processes-0.8.0 app/commands/decidim/participatory_processes/admin/update_participatory_process_step.rb
decidim-participatory_processes-0.7.4 app/commands/decidim/participatory_processes/admin/update_participatory_process_step.rb
decidim-participatory_processes-0.7.3 app/commands/decidim/participatory_processes/admin/update_participatory_process_step.rb
decidim-participatory_processes-0.7.2 app/commands/decidim/participatory_processes/admin/update_participatory_process_step.rb
decidim-participatory_processes-0.7.1 app/commands/decidim/participatory_processes/admin/update_participatory_process_step.rb
decidim-participatory_processes-0.7.0 app/commands/decidim/participatory_processes/admin/update_participatory_process_step.rb
decidim-participatory_processes-0.6.8 app/commands/decidim/participatory_processes/admin/update_participatory_process_step.rb
decidim-0.6.8 decidim-participatory_processes/app/commands/decidim/participatory_processes/admin/update_participatory_process_step.rb
decidim-participatory_processes-0.6.7 app/commands/decidim/participatory_processes/admin/update_participatory_process_step.rb
decidim-0.6.7 decidim-participatory_processes/app/commands/decidim/participatory_processes/admin/update_participatory_process_step.rb
decidim-participatory_processes-0.6.6 app/commands/decidim/participatory_processes/admin/update_participatory_process_step.rb
decidim-0.6.6 decidim-participatory_processes/app/commands/decidim/participatory_processes/admin/update_participatory_process_step.rb