Sha256: 621ca3ff6f8e7f07bb1064186ea2fd205f98404ba95719d3bdfe76eea9641111

Contents?: true

Size: 894 Bytes

Versions: 6

Compression:

Stored size: 894 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Elections
    module TrusteeZone
      # This command allows the user to update their trustee information
      class UpdateTrustee < Rectify::Command
        # Public: Initializes the command.
        #
        # form - A form with the new trustee information
        def initialize(form)
          @form = form
        end

        # Update the trustee if valid.
        #
        # Broadcasts :ok if successful, :invalid otherwise.
        def call
          return broadcast(:invalid) if form.invalid?

          update_trustee!

          broadcast(:ok, trustee)
        end

        private

        attr_reader :form

        delegate :trustee, to: :form

        def update_trustee!
          trustee.update!(
            name: form.name,
            public_key: form.public_key
          )
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
decidim-elections-0.24.3 app/commands/decidim/elections/trustee_zone/update_trustee.rb
decidim-elections-0.24.2 app/commands/decidim/elections/trustee_zone/update_trustee.rb
decidim-elections-0.24.1 app/commands/decidim/elections/trustee_zone/update_trustee.rb
decidim-elections-0.24.0 app/commands/decidim/elections/trustee_zone/update_trustee.rb
decidim-elections-0.24.0.rc2 app/commands/decidim/elections/trustee_zone/update_trustee.rb
decidim-elections-0.24.0.rc1 app/commands/decidim/elections/trustee_zone/update_trustee.rb