Class: Decidim::Amendable::Reject
- Defined in:
- app/commands/decidim/amendable/reject.rb
Overview
A command with all the business logic to reject an amend.
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(form) ⇒ Reject
constructor
Public: Initializes the command.
Methods inherited from Command
call, #evaluate, #method_missing, #respond_to_missing?, #transaction
Constructor Details
#initialize(form) ⇒ Reject
Public: Initializes the command.
form - A form object with the params. amendable - The resource that is being amended.
11 12 13 14 15 16 |
# File 'app/commands/decidim/amendable/reject.rb', line 11 def initialize(form) @form = form @amendment = form.amendment @amendable = form.amendable @emendation = form.emendation end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Decidim::Command
Instance Method Details
#call ⇒ Object
Executes the command. Broadcasts these events:
-
:ok when everything is valid, together with the amend.
-
:invalid if the form wasn’t valid and we couldn’t proceed.
Returns nothing.
24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/commands/decidim/amendable/reject.rb', line 24 def call return broadcast(:invalid) if @form.invalid? transaction do reject_amendment! notify_emendation_state_change! end broadcast(:ok, @emendation) end |