Class: Decidim::Votings::CertifyPollingStationClosure
- Inherits:
-
Command
- Object
- Command
- Decidim::Votings::CertifyPollingStationClosure
- Includes:
- GalleryMethods
- Defined in:
- app/commands/decidim/votings/certify_polling_station_closure.rb
Overview
A command with all the business logic when signing a closure of a polling station
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(form, closure) ⇒ CertifyPollingStationClosure
constructor
Public: Initializes the command.
Constructor Details
#initialize(form, closure) ⇒ CertifyPollingStationClosure
Public: Initializes the command.
form - A form object with the params. closure - A closure object.
12 13 14 15 16 |
# File 'app/commands/decidim/votings/certify_polling_station_closure.rb', line 12 def initialize(form, closure) @form = form @closure = closure @attached_to = closure end |
Instance Method Details
#call ⇒ Object
Executes the command. Broadcasts these events:
-
:ok when everything is valid.
-
:invalid if the form was not valid and we could not proceed.
Returns nothing.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/commands/decidim/votings/certify_polling_station_closure.rb', line 24 def call return broadcast(:invalid) if form.invalid? if process_gallery? build_gallery return broadcast(:invalid) if gallery_invalid? end transaction do create_gallery if process_gallery? closure.update!(phase: :signature) end broadcast(:ok) end |