Class: Decidim::Posts::UpdatePost

Inherits:
Command
  • Object
show all
Includes:
MultipleAttachmentsMethods
Defined in:
app/commands/decidim/posts/update_post.rb

Instance Method Summary collapse

Constructor Details

#initialize(form, current_user, post) ⇒ UpdatePost

Returns a new instance of UpdatePost.



6
7
8
9
10
11
# File 'app/commands/decidim/posts/update_post.rb', line 6

def initialize(form, current_user, post)
  @form = form
  @current_user = current_user
  @post = post
  @attached_to = post
end

Instance Method Details

#callObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/commands/decidim/posts/update_post.rb', line 13

def call
  return broadcast(:invalid) if invalid?

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

  with_events(with_transaction: true) do
    #Decidim.traceability.perform_action!("update_feeds_post", Post, form.current_user) do
    update_post
    #end
    document_cleanup!(include_all_attachments: true)
    create_attachments if process_attachments?
  end


  broadcast(:ok, @post)
end