Class: Decidim::Accountability::Admin::CreateResult

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

Overview

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

Instance Method Summary collapse

Constructor Details

#initialize(form) ⇒ CreateResult

Returns a new instance of CreateResult.


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

def initialize(form)
  @form = form
end

Instance Method Details

#callObject

Creates the result if valid.

Broadcasts :ok if successful, :invalid otherwise.


16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'decidim-accountability/app/commands/decidim/accountability/admin/create_result.rb', line 16

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

  transaction do
    create_result
    link_meetings
    link_proposals
    link_projects
    notify_proposal_followers
  end

  broadcast(:ok)
end