Class: Decidim::Accountability::Admin::CreateImportedResult

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

Overview

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

Instance Method Summary collapse

Methods inherited from Command

call, #evaluate, #method_missing, #respond_to_missing?, #transaction

Constructor Details

#initialize(form, parent_id = nil) ⇒ CreateImportedResult

Returns a new instance of CreateImportedResult.


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

def initialize(form, parent_id = nil)
  @form = form
  @parent_id = parent_id
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Decidim::Command

Instance Method Details

#callObject

Creates the result if valid.

Broadcasts :ok if successful, :invalid otherwise.


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

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