Sha256: 14aefddde49b41a8981d3103233807e62d38e588ee515dbb88089ec6d895f3f9

Contents?: true

Size: 1.08 KB

Versions: 7

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

module Decidim
  module Votings
    module Admin
      # A command with all the business logic for a monitornig committee member to validate a polling station closure
      class MonitoringCommitteeValidatePollingStationClosure < Decidim::Command
        # Public: Initializes the command.
        #
        # form - A form object with the params.
        # closure - A closure object.
        def initialize(form, closure)
          @form = form
          @closure = closure
        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?

          closure.update!(validated_at: Time.current, monitoring_committee_notes: form.monitoring_committee_notes)

          broadcast(:ok)
        rescue ActiveRecord::RecordInvalid
          broadcast(:invalid)
        end

        attr_reader :form, :closure
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
decidim-elections-0.28.4 app/commands/decidim/votings/admin/monitoring_committee_validate_polling_station_closure.rb
decidim-elections-0.28.3 app/commands/decidim/votings/admin/monitoring_committee_validate_polling_station_closure.rb
decidim-elections-0.28.2 app/commands/decidim/votings/admin/monitoring_committee_validate_polling_station_closure.rb
decidim-elections-0.28.1 app/commands/decidim/votings/admin/monitoring_committee_validate_polling_station_closure.rb
decidim-elections-0.28.0 app/commands/decidim/votings/admin/monitoring_committee_validate_polling_station_closure.rb
decidim-elections-0.28.0.rc5 app/commands/decidim/votings/admin/monitoring_committee_validate_polling_station_closure.rb
decidim-elections-0.28.0.rc4 app/commands/decidim/votings/admin/monitoring_committee_validate_polling_station_closure.rb