Class: Decidim::Lausanne::Budgets::CancelOrder

Inherits:
Command
  • Object
show all
Defined in:
app/commands/decidim/lausanne/budgets/cancel_order.rb

Overview

A command with all the business to cancel an order.

Instance Method Summary collapse

Constructor Details

#initialize(order) ⇒ CancelOrder

Public: Initializes the command.

order - The current order for the user.



11
12
13
# File 'app/commands/decidim/lausanne/budgets/cancel_order.rb', line 11

def initialize(order)
  @order = order
end

Instance Method Details

#callObject

Executes the command. Broadcasts these events:

  • :ok when everything is valid.

Returns nothing.



20
21
22
23
24
25
# File 'app/commands/decidim/lausanne/budgets/cancel_order.rb', line 20

def call
  transaction do
    cancel_order!
  end
  broadcast(:ok, @order)
end