Class: Decidim::ParticipatoryDocuments::Admin::CreateSuggestionNote

Inherits:
Command
  • Object
show all
Defined in:
app/commands/decidim/participatory_documents/admin/create_suggestion_note.rb

Instance Method Summary collapse

Constructor Details

#initialize(form, suggestion) ⇒ CreateSuggestionNote

Public: Initializes the command.

form - A form object with the params. suggestion - the suggestion to relate.



11
12
13
14
# File 'app/commands/decidim/participatory_documents/admin/create_suggestion_note.rb', line 11

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

Instance Method Details

#callObject

Executes the command. Broadcasts these events:

  • :ok when everything is valid, together with the note proposal.

  • :invalid if the form wasn’t valid and we couldn’t proceed.

Returns nothing.



22
23
24
25
26
27
28
29
# File 'app/commands/decidim/participatory_documents/admin/create_suggestion_note.rb', line 22

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

  create_suggestion_note
  # notify_admins_and_valuators

  broadcast(:ok, suggestion_note)
end