Class: Decidim::Votings::Admin::MonitoringCommitteeValidatePollingStationClosure
- Inherits:
-
Command
- Object
- Command
- Decidim::Votings::Admin::MonitoringCommitteeValidatePollingStationClosure
- Defined in:
- app/commands/decidim/votings/admin/monitoring_committee_validate_polling_station_closure.rb
Overview
A command with all the business logic for a monitornig committee member to validate a polling station closure
Instance Attribute Summary collapse
-
#closure ⇒ Object
readonly
Returns the value of attribute closure.
-
#form ⇒ Object
readonly
Returns the value of attribute form.
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(form, closure) ⇒ MonitoringCommitteeValidatePollingStationClosure
constructor
Public: Initializes the command.
Constructor Details
#initialize(form, closure) ⇒ MonitoringCommitteeValidatePollingStationClosure
Public: Initializes the command.
form - A form object with the params. closure - A closure object.
12 13 14 15 |
# File 'app/commands/decidim/votings/admin/monitoring_committee_validate_polling_station_closure.rb', line 12 def initialize(form, closure) @form = form @closure = closure end |
Instance Attribute Details
#closure ⇒ Object (readonly)
Returns the value of attribute closure.
33 34 35 |
# File 'app/commands/decidim/votings/admin/monitoring_committee_validate_polling_station_closure.rb', line 33 def closure @closure end |
#form ⇒ Object (readonly)
Returns the value of attribute form.
33 34 35 |
# File 'app/commands/decidim/votings/admin/monitoring_committee_validate_polling_station_closure.rb', line 33 def form @form 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.
23 24 25 26 27 28 29 30 31 |
# File 'app/commands/decidim/votings/admin/monitoring_committee_validate_polling_station_closure.rb', line 23 def call return broadcast(:invalid) if form.invalid? closure.update!(validated_at: Time.current, monitoring_committee_notes: form.monitoring_committee_notes) broadcast(:ok) rescue ActiveRecord::RecordInvalid broadcast(:invalid) end |