Class: Decidim::Proposals::Admin::CreateProposalNote
- Inherits:
-
Command
- Object
- Command
- Decidim::Proposals::Admin::CreateProposalNote
- Defined in:
- app/commands/decidim/proposals/admin/create_proposal_note.rb
Overview
A command with all the business logic when an admin creates a private note proposal.
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(form, proposal) ⇒ CreateProposalNote
constructor
Public: Initializes the command.
Constructor Details
#initialize(form, proposal) ⇒ CreateProposalNote
Public: Initializes the command.
form - A form object with the params. proposal - the proposal to relate.
12 13 14 15 |
# File 'app/commands/decidim/proposals/admin/create_proposal_note.rb', line 12 def initialize(form, proposal) @form = form @proposal = proposal end |
Instance Method Details
#call ⇒ Object
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.
23 24 25 26 27 28 29 30 |
# File 'app/commands/decidim/proposals/admin/create_proposal_note.rb', line 23 def call return broadcast(:invalid) if form.invalid? create_proposal_note notify_admins_and_valuators broadcast(:ok, proposal_note) end |