Sha256: 3baa44fbde00b16187d851d9c87451fe56f36c322c2988b5c70cc0a45738760f

Contents?: true

Size: 1.07 KB

Versions: 19

Compression:

Stored size: 1.07 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 < Rectify::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 wasn't valid and we couldn't 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

19 entries across 19 versions & 1 rubygems

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