Class: Decidim::Budgets::Admin::UpdateProjectSelection
- Inherits:
-
Command
- Object
- Command
- Decidim::Budgets::Admin::UpdateProjectSelection
- Includes:
- TranslatableAttributes
- Defined in:
- app/commands/decidim/budgets/admin/update_project_selection.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(selection, project_ids) ⇒ UpdateProjectSelection
constructor
Public: Initializes the command.
Constructor Details
#initialize(selection, project_ids) ⇒ UpdateProjectSelection
Public: Initializes the command.
selection - Defines if projects are selected (for implementation) project_ids - the project ids to update.
13 14 15 16 17 |
# File 'app/commands/decidim/budgets/admin/update_project_selection.rb', line 13 def initialize(selection, project_ids) @selection = selection @project_ids = project_ids @response = { selection_name: "", successful: [], errored: [] } end |
Instance Method Details
#call ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'app/commands/decidim/budgets/admin/update_project_selection.rb', line 19 def call return broadcast(:invalid_selection) if @selection.blank? || [true, false, "true", "false"].exclude?(@selection) return broadcast(:invalid_project_ids) if @project_ids.blank? @selection = ActiveModel::Type::Boolean.new.cast(@selection) update_projects_selection broadcast(:update_projects_selection, @response) end |