Sha256: ac761456b8e61ba454b543e81d441b0452665793eaccb15b7d0f0102056cb41c
Contents?: true
Size: 886 Bytes
Versions: 56
Compression:
Stored size: 886 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. # feature - The current feature. def initialize(order, feature) @order = order @feature = feature 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
56 entries across 56 versions & 2 rubygems