Class: Decidim::Accountability::Admin::UpdateResultDates
- Inherits:
-
Command
- Object
- Command
- Decidim::Accountability::Admin::UpdateResultDates
- Defined in:
- app/commands/decidim/accountability/admin/update_result_dates.rb
Overview
A command with all the business logic when an admin batch updates results dates.
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(start_date, end_date, result_ids, current_user) ⇒ UpdateResultDates
constructor
Public: Initializes the command.
Constructor Details
#initialize(start_date, end_date, result_ids, current_user) ⇒ UpdateResultDates
Public: Initializes the command.
start_date - the start date to update end_date - the end date to update result_ids - the results ids to update current_user - the user performing the action
14 15 16 17 18 19 |
# File 'app/commands/decidim/accountability/admin/update_result_dates.rb', line 14 def initialize(start_date, end_date, result_ids, current_user) @start_date = start_date @end_date = end_date @result_ids = result_ids @current_user = current_user 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.
27 28 29 30 31 32 33 |
# File 'app/commands/decidim/accountability/admin/update_result_dates.rb', line 27 def call return broadcast(:invalid) if (start_date.blank? && end_date.blank?) || result_ids.blank? update_results_dates broadcast(:ok) end |