Sha256: 78875d605ac838fd1b943881fb8ef7fd7ad7dac5626ba51399220ed1467ca72f
Contents?: true
Size: 878 Bytes
Versions: 3
Compression:
Stored size: 878 Bytes
Contents
module ShoppingCart class ProceedCheckout < Rectify::Command def initialize(params, order, step) @params = params @order = order @step = step end 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 private def call_custom_command custom_command = "ShoppingCart::#{@step.to_s.camelcase}CheckoutStep" custom_command.constantize.call(@order, @params) end end end
Version data entries
3 entries across 3 versions & 1 rubygems