Class: Decidim::Accountability::Admin::UpdateTimelineEntry

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

Overview

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

Instance Method Summary collapse

Constructor Details

#initialize(form, timeline_entry) ⇒ UpdateTimelineEntry

Initializes an UpdateTimelineEntry Command.

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


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

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

Instance Method Details

#callObject

Updates the timeline_entry if valid.

Broadcasts :ok if successful, :invalid otherwise.


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

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

  transaction do
    update_timeline_entry
  end

  broadcast(:ok)
end