Class: Decidim::Elections::Admin::CreateQuestion
- Inherits:
-
Command
- Object
- Command
- Decidim::Elections::Admin::CreateQuestion
- Defined in:
- app/commands/decidim/elections/admin/create_question.rb
Overview
This command is executed when the user creates a Question from the admin panel.
Instance Method Summary collapse
-
#call ⇒ Object
Creates the question if valid.
-
#initialize(form) ⇒ CreateQuestion
constructor
A new instance of CreateQuestion.
Constructor Details
#initialize(form) ⇒ CreateQuestion
Returns a new instance of CreateQuestion.
9 10 11 |
# File 'app/commands/decidim/elections/admin/create_question.rb', line 9 def initialize(form) @form = form end |
Instance Method Details
#call ⇒ Object
Creates the question if valid.
Broadcasts :ok if successful, :invalid otherwise.
16 17 18 19 20 21 22 23 |
# File 'app/commands/decidim/elections/admin/create_question.rb', line 16 def call return broadcast(:election_started) if form.election.blocked? return broadcast(:invalid) if form.invalid? create_question! broadcast(:ok, question) end |