Sha256: e5da95195c9472ac4fb1b8579535773fedbc16dd6de95ba7da868c91d153c69a
Contents?: true
Size: 1.02 KB
Versions: 62
Compression:
Stored size: 1.02 KB
Contents
module Workarea class Payment class Operation attr_reader :transactions, :errors def initialize(transactions, options = {}) @transactions = transactions @options = options @errors = [] end def success? errors.empty? end def complete! begin complete_each_transaction! rescue Exception => e rollback! raise e ensure add_transaction_errors end end def rollback! transactions .select(&:success?) .reject(&:canceled?) .each { |t| t.cancel!(@options) } end private def complete_each_transaction! transactions.each do |transaction| transaction.complete!(@options) rollback! and break if transaction.failure? end end def add_transaction_errors transactions.select(&:failure?).each do |transaction| errors << transaction.message end end end end end
Version data entries
62 entries across 62 versions & 1 rubygems
Version | Path |
---|---|
workarea-core-3.4.13 | app/models/workarea/payment/operation.rb |
workarea-core-3.4.12 | app/models/workarea/payment/operation.rb |