Class: Decidim::Budgets::RemoveLineItem

Inherits:
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

Methods inherited from Command

call, #evaluate, #method_missing, #respond_to_missing?, #transaction, #with_events

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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Decidim::Command

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