Class: Decidim::Budgets::RemoveLineItem

Inherits:
Rectify::Command
  • Object
show all
Defined in:
decidim-budgets/app/commands/decidim/budgets/remove_line_item.rb

Overview

A command with all the business to add remove line items from orders

Instance Method Summary collapse

Constructor Details

#initialize(order, project) ⇒ RemoveLineItem

Public: Initializes the command.

order - The current order for the user project - The the project to remove from the order


11
12
13
14
# File 'decidim-budgets/app/commands/decidim/budgets/remove_line_item.rb', line 11

def initialize(order, project)
  @order = order
  @project = project
end

Instance Method Details

#callObject

Executes the command. Broadcasts these events:

  • :ok when everything is valid.

  • :invalid if the there is an error.

Returns nothing.


22
23
24
25
26
27
# File 'decidim-budgets/app/commands/decidim/budgets/remove_line_item.rb', line 22

def call
  return broadcast(:invalid) if @order.checked_out?

  remove_line_item
  broadcast(:ok, @order)
end