Sha256: f52aad30f775bd083cc2acd9c4e47ebf43a4da8ad7b4c2d20ba94b875ab5de9b

Contents?: true

Size: 869 Bytes

Versions: 19

Compression:

Stored size: 869 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Votings
    # A command to check if census data is given
    class CheckCensus < Rectify::Command
      def initialize(form)
        @form = form
      end

      # Executes the command. Broadcast this events:
      # - :ok when census is found
      # - :invalid when the form is not valid
      # - :not_found when census is not found
      #
      # Returns nothing.
      def call
        return broadcast(:invalid) unless form.valid?

        check_census
      end

      attr_reader :form, :session

      def check_census
        datum = Decidim::Votings::Census::Datum.find_by(dataset: form.current_participatory_space.dataset, hashed_check_data: form.hashed_check_data)
        if datum
          broadcast(:ok, datum)
        else
          broadcast(:not_found)
        end
      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/check_census.rb
decidim-elections-0.26.9 app/commands/decidim/votings/check_census.rb
decidim-elections-0.26.8 app/commands/decidim/votings/check_census.rb
decidim-elections-0.26.7 app/commands/decidim/votings/check_census.rb
decidim-elections-0.26.5 app/commands/decidim/votings/check_census.rb
decidim-elections-0.26.4 app/commands/decidim/votings/check_census.rb
decidim-elections-0.26.3 app/commands/decidim/votings/check_census.rb
decidim-elections-0.26.2 app/commands/decidim/votings/check_census.rb
decidim-elections-0.26.1 app/commands/decidim/votings/check_census.rb
decidim-elections-0.26.0 app/commands/decidim/votings/check_census.rb
decidim-elections-0.26.0.rc2 app/commands/decidim/votings/check_census.rb
decidim-elections-0.26.0.rc1 app/commands/decidim/votings/check_census.rb
decidim-elections-0.25.2 app/commands/decidim/votings/check_census.rb
decidim-elections-0.25.1 app/commands/decidim/votings/check_census.rb
decidim-elections-0.25.0 app/commands/decidim/votings/check_census.rb
decidim-elections-0.25.0.rc4 app/commands/decidim/votings/check_census.rb
decidim-elections-0.25.0.rc3 app/commands/decidim/votings/check_census.rb
decidim-elections-0.25.0.rc2 app/commands/decidim/votings/check_census.rb
decidim-elections-0.25.0.rc1 app/commands/decidim/votings/check_census.rb