Class: Decidim::Accountability::Admin::UpdateStatus

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

Overview

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

Instance Method Summary collapse

Constructor Details

#initialize(form, status, user) ⇒ UpdateStatus

Initializes an UpdateStatus Command.

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


13
14
15
16
17
# File 'decidim-accountability/app/commands/decidim/accountability/admin/update_status.rb', line 13

def initialize(form, status, user)
  @form = form
  @status = status
  @user = user
end

Instance Method Details

#callObject

Updates the status if valid.

Broadcasts :ok if successful, :invalid otherwise.


22
23
24
25
26
27
28
29
30
# File 'decidim-accountability/app/commands/decidim/accountability/admin/update_status.rb', line 22

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

  transaction do
    update_status
  end

  broadcast(:ok)
end