Class: Decidim::Debates::CreateDebate
- Inherits:
-
Command
- Object
- Command
- Decidim::Debates::CreateDebate
- Defined in:
- decidim-debates/app/commands/decidim/debates/create_debate.rb
Overview
This command is executed when the user creates a Debate from the public views.
Instance Method Summary collapse
-
#call ⇒ Object
Creates the debate if valid.
-
#initialize(form) ⇒ CreateDebate
constructor
A new instance of CreateDebate.
Constructor Details
#initialize(form) ⇒ CreateDebate
Returns a new instance of CreateDebate.
8 9 10 |
# File 'decidim-debates/app/commands/decidim/debates/create_debate.rb', line 8 def initialize(form) @form = form end |
Instance Method Details
#call ⇒ Object
Creates the debate if valid.
Broadcasts :ok if successful, :invalid otherwise.
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'decidim-debates/app/commands/decidim/debates/create_debate.rb', line 15 def call return broadcast(:invalid) if form.invalid? transaction do create_debate send_notification_to_space_followers end follow_debate broadcast(:ok, debate) end |