Class: Decidim::Elections::Admin::CreateQuestion

Inherits:
Rectify::Command
  • Object
show all
Defined in:
decidim-elections/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

Constructor Details

#initialize(form) ⇒ CreateQuestion

Returns a new instance of CreateQuestion.


9
10
11
# File 'decidim-elections/app/commands/decidim/elections/admin/create_question.rb', line 9

def initialize(form)
  @form = form
end

Instance Method Details

#callObject

Creates the question if valid.

Broadcasts :ok if successful, :invalid otherwise.


16
17
18
19
20
21
22
# File 'decidim-elections/app/commands/decidim/elections/admin/create_question.rb', line 16

def call
  return broadcast(:invalid) if invalid?

  create_question!

  broadcast(:ok, question)
end