Module: SuperSettings::Storage::Transaction::ClassMethods
- Defined in:
- lib/super_settings/storage/transaction.rb
Instance Method Summary collapse
Instance Method Details
#save_all(changes) ⇒ Object
34 35 36 37 38 |
# File 'lib/super_settings/storage/transaction.rb', line 34 def save_all(changes) # :nocov: raise NotImplementedError # :nocov: end |
#transaction(&block) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/super_settings/storage/transaction.rb', line 13 def transaction(&block) if Thread.current[transaction_key] yield Thread.current[transaction_key] else begin changes = [] Thread.current[transaction_key] = changes yield(changes) if save_all(changes) != false changes.each do |object| object.persisted = true if object.respond_to?(:persisted=) end end ensure Thread.current[transaction_key] = nil end end end |