Class: Decidim::Elections::Admin::UnpublishElection

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

Overview

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

Instance Method Summary collapse

Constructor Details

#initialize(election, current_user) ⇒ UnpublishElection

Public: Initializes the command.

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


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

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

Instance Method Details

#callObject

Public: Unpublishes the Election.

Broadcasts :ok if unpublished, :invalid otherwise.


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

def call
  unpublish_election

  broadcast(:ok)
end