Sha256: dfe81241c8e7ad40ada9a0b263945e0ec06ce143e7632d75e5acd812727aee89

Contents?: true

Size: 1.13 KB

Versions: 35

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

module Decidim
  module Assemblies
    module Admin
      # A command with all the business logic when updating a new assembly
      # type in the system.
      class UpdateAssembliesType < Rectify::Command
        # Public: Initializes the command.
        #
        # assemblies_type - A assemblies_type object to update.
        # form - A form object with the params.
        def initialize(assemblies_type, form)
          @assemblies_type = assemblies_type
          @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_assemblies_type!

          broadcast(:ok)
        end

        private

        attr_reader :form

        def update_assemblies_type!
          Decidim.traceability.update!(
            @assemblies_type,
            form.current_user,
            title: form.title
          )
        end
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
decidim-assemblies-0.26.10 app/commands/decidim/assemblies/admin/update_assemblies_type.rb
decidim-assemblies-0.26.9 app/commands/decidim/assemblies/admin/update_assemblies_type.rb
decidim-assemblies-0.26.8 app/commands/decidim/assemblies/admin/update_assemblies_type.rb
decidim-assemblies-0.26.7 app/commands/decidim/assemblies/admin/update_assemblies_type.rb
decidim-assemblies-0.26.5 app/commands/decidim/assemblies/admin/update_assemblies_type.rb
decidim-assemblies-0.26.4 app/commands/decidim/assemblies/admin/update_assemblies_type.rb
decidim-assemblies-0.26.3 app/commands/decidim/assemblies/admin/update_assemblies_type.rb
decidim-assemblies-0.26.2 app/commands/decidim/assemblies/admin/update_assemblies_type.rb
decidim-assemblies-0.26.1 app/commands/decidim/assemblies/admin/update_assemblies_type.rb
decidim-assemblies-0.26.0 app/commands/decidim/assemblies/admin/update_assemblies_type.rb
decidim-assemblies-0.26.0.rc2 app/commands/decidim/assemblies/admin/update_assemblies_type.rb
decidim-assemblies-0.26.0.rc1 app/commands/decidim/assemblies/admin/update_assemblies_type.rb
decidim-assemblies-0.25.2 app/commands/decidim/assemblies/admin/update_assemblies_type.rb
decidim-assemblies-0.25.1 app/commands/decidim/assemblies/admin/update_assemblies_type.rb
decidim-assemblies-0.25.0 app/commands/decidim/assemblies/admin/update_assemblies_type.rb
decidim-assemblies-0.25.0.rc4 app/commands/decidim/assemblies/admin/update_assemblies_type.rb
decidim-assemblies-0.25.0.rc3 app/commands/decidim/assemblies/admin/update_assemblies_type.rb
decidim-assemblies-0.25.0.rc2 app/commands/decidim/assemblies/admin/update_assemblies_type.rb
decidim-assemblies-0.25.0.rc1 app/commands/decidim/assemblies/admin/update_assemblies_type.rb
decidim-assemblies-0.24.3 app/commands/decidim/assemblies/admin/update_assemblies_type.rb