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

Inherits:
Commands::UpdateResource
  • Object
show all
Includes:
MultipleAttachmentsMethods
Defined in:
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

Instance Method Details

#callObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/commands/decidim/debates/admin/update_debate.rb', line 13

def call
  return broadcast(:invalid) if invalid?

  if process_attachments?
    build_attachments
    return broadcast(:invalid) if attachments_invalid?
  end

  perform!
  broadcast(:ok, resource)
rescue ActiveRecord::RecordInvalid
  add_file_attribute_errors!
  broadcast(:invalid)
rescue Decidim::Commands::HookError
  broadcast(:invalid)
end