Sha256: 5383cd518f92042d61db9f3b2d4420621b3c204b94ee3ef4c1e162d9fd96b1e4
Contents?: true
Size: 792 Bytes
Versions: 39
Compression:
Stored size: 792 Bytes
Contents
# frozen_string_literal: true module Decidim module Budgets # A command with all the business to cancel an order. class CancelOrder < Rectify::Command # Public: Initializes the command. # # order - The current order for the user. def initialize(order) @order = order end # Executes the command. Broadcasts these events: # # - :ok when everything is valid. # - :invalid if the there is an error. # # Returns nothing. def call return broadcast(:invalid) if invalid_order? cancel_order! broadcast(:ok, @order) end private def invalid_order? !@order&.checked_out? end def cancel_order! @order.destroy! end end end end
Version data entries
39 entries across 39 versions & 1 rubygems