Module: ActiveInteraction::Extras::Transaction
- Extended by:
- ActiveSupport::Concern
- Included in:
- All
- Defined in:
- lib/active_interaction/extras/transaction.rb
Instance Method Summary collapse
Instance Method Details
#run_in_transaction! ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/active_interaction/extras/transaction.rb', line 4 def run_in_transaction! result_or_errors = nil ActiveRecord::Base.transaction do result_or_errors = yield # check by class because # errors added by compose method are merged after execute, # so we need to check return type ourselves # # see ActiveInteraction::Runnable#run if result_or_errors.is_a?(ActiveInteraction::Errors) && result_or_errors.any? raise ActiveRecord::Rollback end raise ActiveRecord::Rollback if errors.any? end result_or_errors end |