Class: Decidim::Votings::CertifyPollingStationClosure

Inherits:
Command
  • Object
show all
Includes:
GalleryMethods
Defined in:
decidim-elections/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

Methods inherited from Command

call, #evaluate, #method_missing, #respond_to_missing?, #transaction, #with_events

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 'decidim-elections/app/commands/decidim/votings/certify_polling_station_closure.rb', line 12

def initialize(form, closure)
  @form = form
  @closure = closure
  @attached_to = closure
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Decidim::Command

Instance Method Details

#callObject

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 'decidim-elections/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