Class: Decidim::Accountability::Admin::UpdateResultDates
- Defined in:
- decidim-accountability/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.
Methods inherited from Command
call, #evaluate, #method_missing, #respond_to_missing?, #transaction, #with_events
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 'decidim-accountability/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 |
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
-
:invalid if the form was not valid and we could not proceed.
Returns nothing.
27 28 29 30 31 32 33 |
# File 'decidim-accountability/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 |