Class: Decidim::Budgets::Checkout

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

Overview

A command with all the business to checkout.

Instance Method Summary collapse

Methods inherited from Command

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

Constructor Details

#initialize(order) ⇒ Checkout

Public: Initializes the command.

order - The current order for the user.



10
11
12
# File 'decidim-budgets/app/commands/decidim/budgets/checkout.rb', line 10

def initialize(order)
  @order = order
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.



20
21
22
23
24
# File 'decidim-budgets/app/commands/decidim/budgets/checkout.rb', line 20

def call
  return broadcast(:invalid, order) unless checkout!

  broadcast(:ok, order)
end