Class: ShoppingCart::ProceedCheckout
- Inherits:
-
Rectify::Command
- Object
- Rectify::Command
- ShoppingCart::ProceedCheckout
- Defined in:
- app/commands/shopping_cart/proceed_checkout.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(params, order, step) ⇒ ProceedCheckout
constructor
A new instance of ProceedCheckout.
Constructor Details
#initialize(params, order, step) ⇒ ProceedCheckout
Returns a new instance of ProceedCheckout.
3 4 5 6 7 |
# File 'app/commands/shopping_cart/proceed_checkout.rb', line 3 def initialize(params, order, step) @params = params @order = order @step = step end |
Instance Method Details
#call ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/commands/shopping_cart/proceed_checkout.rb', line 9 def call return broadcast(:invalid) unless @params && @order transaction do case @step when :address then AddCheckoutAddresses.call(@order, @params) when :delivery then AddCheckoutDelivery.call(@order, @params) when :payment then AddCheckoutPayment.call(@order, @params) when :confirm then PlaceOrder.call(@order) else call_custom_command end end @order.errors.any? ? broadcast(:validation) : broadcast(:ok) end |