Class: Decidim::Votings::Admin::PublishVoting
- Inherits:
-
Command
- Object
- Command
- Decidim::Votings::Admin::PublishVoting
- Defined in:
- decidim-elections/app/commands/decidim/votings/admin/publish_voting.rb
Overview
This command gets called when a voting is published from the admin panel.
Instance Method Summary collapse
-
#call ⇒ Object
Public: Publishes the Voting.
-
#initialize(voting, current_user) ⇒ PublishVoting
constructor
Public: Initializes the command.
Constructor Details
#initialize(voting, current_user) ⇒ PublishVoting
Public: Initializes the command.
voting - The voting to publish. current_user - the user performing the action
12 13 14 15 |
# File 'decidim-elections/app/commands/decidim/votings/admin/publish_voting.rb', line 12 def initialize(voting, current_user) @voting = voting @current_user = current_user end |
Instance Method Details
#call ⇒ Object
Public: Publishes the Voting.
Broadcasts :ok if published, :invalid otherwise.
20 21 22 23 24 25 26 |
# File 'decidim-elections/app/commands/decidim/votings/admin/publish_voting.rb', line 20 def call return broadcast(:invalid) if voting.nil? || voting.published? publish_voting broadcast(:ok, voting) end |