Class: Decidim::Budgets::Admin::UpdateProjectScope

Inherits:
Command
  • Object
show all
Includes:
TranslatableAttributes
Defined in:
app/commands/decidim/budgets/admin/update_project_scope.rb

Instance Method Summary collapse

Constructor Details

#initialize(scope_id, project_ids) ⇒ UpdateProjectScope

Public: Initializes the command.

scope_id - the scope id to update project_ids - the project ids to update.



13
14
15
16
17
# File 'app/commands/decidim/budgets/admin/update_project_scope.rb', line 13

def initialize(scope_id, project_ids)
  @scope = ::Decidim::Scope.find_by id: scope_id
  @project_ids = project_ids
  @response = { scope_name: "", successful: [], errored: [] }
end

Instance Method Details

#callObject



19
20
21
22
23
24
25
26
# File 'app/commands/decidim/budgets/admin/update_project_scope.rb', line 19

def call
  return broadcast(:invalid_scope) if @scope.blank?
  return broadcast(:invalid_project_ids) if @project_ids.blank?

  update_projects_scope

  broadcast(:update_projects_scope, @response)
end