Class: Decidim::Elections::Admin::PublishElection

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

Overview

This command gets called when a election is published from the admin panel.

Instance Method Summary collapse

Constructor Details

#initialize(election, current_user) ⇒ PublishElection

Public: Initializes the command.

election - The election to publish. current_user - the user performing the action



12
13
14
15
# File 'app/commands/decidim/elections/admin/publish_election.rb', line 12

def initialize(election, current_user)
  @election = election
  @current_user = current_user
end

Instance Method Details

#callObject

Public: Publishes the Election.

Broadcasts :ok if published, :invalid otherwise.



20
21
22
23
24
25
# File 'app/commands/decidim/elections/admin/publish_election.rb', line 20

def call
  publish_election
  publish_event unless election.previously_published?

  broadcast(:ok, election)
end