Class: Decidim::Budgets::Admin::DestroyBudget
- Defined in:
- decidim-budgets/app/commands/decidim/budgets/admin/destroy_budget.rb
Overview
This command is executed when the user destroys a Budget from the admin panel.
Instance Method Summary collapse
-
#call ⇒ Object
Destroys the budget if valid.
-
#initialize(budget, current_user) ⇒ DestroyBudget
constructor
A new instance of DestroyBudget.
Methods inherited from Command
call, #evaluate, #method_missing, #respond_to_missing?, #transaction, #with_events
Constructor Details
#initialize(budget, current_user) ⇒ DestroyBudget
Returns a new instance of DestroyBudget.
9 10 11 12 |
# File 'decidim-budgets/app/commands/decidim/budgets/admin/destroy_budget.rb', line 9 def initialize(budget, current_user) @budget = budget @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
Destroys the budget if valid.
Broadcasts :ok if successful, :invalid otherwise.
17 18 19 20 21 22 23 |
# File 'decidim-budgets/app/commands/decidim/budgets/admin/destroy_budget.rb', line 17 def call return broadcast(:invalid) if budget.projects.present? destroy_budget! broadcast(:ok, budget) end |