Class: Decidim::Plans::Admin::ExportPlansToBudgets

Inherits:
Rectify::Command
  • Object
show all
Includes:
RichPresenter
Defined in:
app/commands/decidim/plans/admin/export_plans_to_budgets.rb

Overview

A command with all the business logic when an admin exports plans to a single budget component.

Instance Method Summary collapse

Methods included from RichPresenter

#plain_content, #rich_content

Constructor Details

#initialize(form) ⇒ ExportPlansToBudgets

Public: Initializes the command.

form - A form object with the params.



14
15
16
# File 'app/commands/decidim/plans/admin/export_plans_to_budgets.rb', line 14

def initialize(form)
  @form = form
end

Instance Method Details

#callObject

Executes the command. Broadcasts these events:

  • :ok when everything is valid.

  • :invalid if the form wasn’t valid and we couldn’t proceed.

Returns nothing.



24
25
26
27
28
# File 'app/commands/decidim/plans/admin/export_plans_to_budgets.rb', line 24

def call
  return broadcast(:invalid) unless @form.valid?

  broadcast(:ok, create_projects_from_closed_plans)
end