Class: Decidim::Elections::Admin::UpdateActionStatus

Inherits:
Rectify::Command
  • Object
show all
Defined in:
decidim-elections/app/commands/decidim/elections/admin/update_action_status.rb

Overview

This command updates the status of the action and the election if it got changed

Instance Method Summary collapse

Constructor Details

#initialize(action) ⇒ UpdateActionStatus

Public: Initializes the command.

action - The pending action to be updated


11
12
13
# File 'decidim-elections/app/commands/decidim/elections/admin/update_action_status.rb', line 11

def initialize(action)
  @action = action
end

Instance Method Details

#callObject

Update the statuses of the action and the election if pending message status got changed.

Broadcasts :ok if successful, :invalid otherwise.


18
19
20
21
22
23
24
25
26
27
# File 'decidim-elections/app/commands/decidim/elections/admin/update_action_status.rb', line 18

def call
  return broadcast(:ok) unless action.pending?

  transaction do
    update_pending_message_status
    update_election_status if action.accepted?
  end

  broadcast(:ok)
end