Module: Quiver::Mappers::ActiveRecordTransaction
- Defined in:
- lib/quiver/mappers.rb
Class Method Summary collapse
Class Method Details
.transaction(root_module, &block) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/quiver/mappers.rb', line 54 def self.transaction(root_module, &block) raise ArgumentError, "#transaction requires a block" unless block_given? transaction = Transaction.new ret = nil ActiveRecord::Base.transaction do begin ret = block.call(transaction) rescue ::ActiveRecord::ActiveRecordError, RollbackTransaction transaction.rollback! end raise ActiveRecord::Rollback if transaction.rollback? end ret end |