Class: Decidim::Accountability::Admin::CreateStatus

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

Overview

This command is executed when the user creates a Status from the admin panel.

Instance Method Summary collapse

Constructor Details

#initialize(form) ⇒ CreateStatus

Returns a new instance of CreateStatus.


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

def initialize(form)
  @form = form
end

Instance Method Details

#callObject

Creates the status if valid.

Broadcasts :ok if successful, :invalid otherwise.


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

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

  transaction do
    create_status
  end

  broadcast(:ok)
end