Sha256: af2f492e43a5d2ad8c4a870ad80e070a4bf30ddda43263d99c28db5fa1513596

Contents?: true

Size: 1.13 KB

Versions: 12

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 < Decidim::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

12 entries across 12 versions & 1 rubygems

Version Path
decidim-assemblies-0.27.9 app/commands/decidim/assemblies/admin/update_assemblies_type.rb
decidim-assemblies-0.27.8 app/commands/decidim/assemblies/admin/update_assemblies_type.rb
decidim-assemblies-0.27.7 app/commands/decidim/assemblies/admin/update_assemblies_type.rb
decidim-assemblies-0.27.6 app/commands/decidim/assemblies/admin/update_assemblies_type.rb
decidim-assemblies-0.27.5 app/commands/decidim/assemblies/admin/update_assemblies_type.rb
decidim-assemblies-0.27.4 app/commands/decidim/assemblies/admin/update_assemblies_type.rb
decidim-assemblies-0.27.3 app/commands/decidim/assemblies/admin/update_assemblies_type.rb
decidim-assemblies-0.27.2 app/commands/decidim/assemblies/admin/update_assemblies_type.rb
decidim-assemblies-0.27.1 app/commands/decidim/assemblies/admin/update_assemblies_type.rb
decidim-assemblies-0.27.0 app/commands/decidim/assemblies/admin/update_assemblies_type.rb
decidim-assemblies-0.27.0.rc2 app/commands/decidim/assemblies/admin/update_assemblies_type.rb
decidim-assemblies-0.27.0.rc1 app/commands/decidim/assemblies/admin/update_assemblies_type.rb