Sha256: 9a648f28041aa00fb7b5f596b88e0f8256f1a40e7572308bf62df63b48c2e541
Contents?: true
Size: 543 Bytes
Versions: 1
Compression:
Stored size: 543 Bytes
Contents
module Conformista # Provides transactional functionality to form objects, wrapping persistence # operations in a database transaction to ensure either all presented models # are persisted, or none are. module Transactions def self.included(base) base.around_persist :wrap_in_database_transaction end private def wrap_in_database_transaction ActiveRecord::Base.transaction do yield.tap do |all_saved| raise ActiveRecord::Rollback unless all_saved end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
conformista-0.0.1 | lib/conformista/transactions.rb |