Class: Decidim::Admin::UpdateAttachment

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

Overview

A command with all the business logic to update an attachment from a participatory process.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attachment, form) ⇒ UpdateAttachment

Public: Initializes the command.

attachment - the Attachment to update form - A form object with the params.


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

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

Instance Attribute Details

#attachmentObject (readonly)

Returns the value of attribute attachment


8
9
10
# File 'decidim-admin/app/commands/decidim/admin/update_attachment.rb', line 8

def attachment
  @attachment
end

Instance Method Details

#callObject

Executes the command. Broadcasts these events:

  • :ok when everything is valid.

  • :invalid if the form wasn't valid and we couldn't proceed.

Returns nothing.


25
26
27
28
29
30
# File 'decidim-admin/app/commands/decidim/admin/update_attachment.rb', line 25

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

  update_attachment
  broadcast(:ok)
end