Class: Decidim::Elections::Admin::PublishElection
- Defined in:
- decidim-elections/app/commands/decidim/elections/admin/publish_election.rb
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(election, current_user) ⇒ PublishElection
constructor
A command to publish an election.
Methods inherited from Command
call, #evaluate, #method_missing, #respond_to_missing?, #transaction, #with_events
Constructor Details
#initialize(election, current_user) ⇒ PublishElection
11 12 13 14 |
# File 'decidim-elections/app/commands/decidim/elections/admin/publish_election.rb', line 11 def initialize(election, current_user) @election = election @current_user = current_user end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Decidim::Command
Instance Method Details
#call ⇒ Object
Executes the command. Broadcasts these events:
-
:ok when everything is valid.
-
:invalid if the form was not valid and we could not proceed.
Returns nothing.
22 23 24 25 26 27 28 29 30 |
# File 'decidim-elections/app/commands/decidim/elections/admin/publish_election.rb', line 22 def call return broadcast(:invalid) if election.published? transaction do publish_election end broadcast(:ok, election) end |