Class: Decidim::Accountability::Admin::CreateTimelineEntry

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

Overview

This command is executed when the user creates a TimelineEntry for a Result from the admin panel.

Instance Method Summary collapse

Constructor Details

#initialize(form, user) ⇒ CreateTimelineEntry

Returns a new instance of CreateTimelineEntry.


9
10
11
12
# File 'decidim-accountability/app/commands/decidim/accountability/admin/create_timeline_entry.rb', line 9

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

Instance Method Details

#callObject

Creates the timeline_entry if valid.

Broadcasts :ok if successful, :invalid otherwise.


17
18
19
20
21
22
23
24
25
# File 'decidim-accountability/app/commands/decidim/accountability/admin/create_timeline_entry.rb', line 17

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

  transaction do
    create_timeline_entry
  end

  broadcast(:ok)
end