Class: Decidim::Debates::Admin::UpdateDebate

Inherits:
Command
  • Object
show all
Defined in:
decidim-debates/app/commands/decidim/debates/admin/update_debate.rb

Overview

This command is executed when the user changes a Debate from the admin panel.

Instance Method Summary collapse

Constructor Details

#initialize(form, debate) ⇒ UpdateDebate

Initializes a UpdateDebate Command.

form - The form from which to get the data. debate - The current instance of the page to be updated.



13
14
15
16
# File 'decidim-debates/app/commands/decidim/debates/admin/update_debate.rb', line 13

def initialize(form, debate)
  @form = form
  @debate = debate
end

Instance Method Details

#callObject

Updates the debate if valid.

Broadcasts :ok if successful, :invalid otherwise.



21
22
23
24
25
26
# File 'decidim-debates/app/commands/decidim/debates/admin/update_debate.rb', line 21

def call
  return broadcast(:invalid) if form.invalid?

  update_debate
  broadcast(:ok)
end