Class: Decidim::Accountability::Admin::UpdateImportedResult

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

Overview

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

Instance Method Summary collapse

Methods inherited from Command

call, #evaluate, #method_missing, #respond_to_missing?, #transaction, #with_events

Constructor Details

#initialize(form, result, parent_id = nil) ⇒ UpdateImportedResult

Initializes an UpdateResult Command.

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



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

def initialize(form, result, parent_id = nil)
  @form = form
  @result = result
  @parent_id = parent_id
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Decidim::Command

Instance Method Details

#callObject

Updates the result if valid.

Broadcasts :ok if successful, :invalid otherwise.



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'decidim-accountability/app/commands/decidim/accountability/admin/update_imported_result.rb', line 22

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

  transaction do
    update_result
    link_proposals
    link_meetings
    link_projects
    send_notifications if should_notify_followers?
  end

  broadcast(:ok)
end