Sha256: 9eaee9af6a928212f121dada64957617edd8a371cfb3c5c63e1cf5d4ea373458
Contents?: true
Size: 1.27 KB
Versions: 19
Compression:
Stored size: 1.27 KB
Contents
# frozen_string_literal: true module Decidim module Votings module Voter # This command updates the in person vote status class UpdateInPersonVoteStatus < Rectify::Command # Public: Initializes the command. # # in_person_vote - the in person vote that has been updated def initialize(in_person_vote) @in_person_vote = in_person_vote end # Update status and send notification # # Broadcasts :ok if successful, :invalid otherwise def call return broadcast(:ok) unless status_changed? transaction do update_vote_status end broadcast(:ok) rescue StandardError => e broadcast(:invalid, e.message) end private attr_reader :in_person_vote, :locale def status_changed? in_person_vote.status != vote_status end def bulletin_board @bulletin_board ||= Decidim::Elections.bulletin_board end def vote_status @vote_status ||= bulletin_board.get_pending_message_status(in_person_vote.message_id) end def update_vote_status in_person_vote.update!(status: vote_status) end end end end end
Version data entries
19 entries across 19 versions & 1 rubygems