Sha256: 3b70fa6807f939621d144cd22b387562bd69fd3b18c5b9d36f330920934aa4d2
Contents?: true
Size: 896 Bytes
Versions: 24
Compression:
Stored size: 896 Bytes
Contents
# frozen_string_literal: true module Decidim module Budgets # A command with all the business to checkout. class Checkout < Rectify::Command # Public: Initializes the command. # # order - The current order for the user. # component - The current component. def initialize(order, component) @order = order @component = component 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, @order) unless checkout! broadcast(:ok, @order) end private def checkout! return unless @order @order.with_lock do @order.checked_out_at = Time.current @order.save end end end end end
Version data entries
24 entries across 24 versions & 1 rubygems