Class: Decidim::Proposals::Admin::ReplyProposalNote

Inherits:
Command
  • Object
show all
Includes:
ProposalNotesMethods
Defined in:
app/commands/decidim/proposals/admin/reply_proposal_note.rb

Overview

A command with all the business logic when an admin creates a private note proposal reply.

Instance Method Summary collapse

Constructor Details

#initialize(form, parent) ⇒ ReplyProposalNote

Public: Initializes the command.

form - A form object with the params. parent - the note to reply.



14
15
16
17
18
# File 'app/commands/decidim/proposals/admin/reply_proposal_note.rb', line 14

def initialize(form, parent)
  @form = form
  @parent = parent
  @proposal = parent.proposal
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 was not valid and we could not proceed.

Returns nothing.



26
27
28
29
30
31
32
33
34
# File 'app/commands/decidim/proposals/admin/reply_proposal_note.rb', line 26

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

  create_proposal_note_reply
  notify_parent_author
  notify_mentioned

  broadcast(:ok, proposal_note)
end