Sha256: 6c1cc05bd362ec7d0c482f73cf6d9e722206dcbd422b5b940e1fb184bf392f72

Contents?: true

Size: 1.07 KB

Versions: 12

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

12 entries across 12 versions & 1 rubygems

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