Class: Transaction::Simple::ThreadSafe::Group

Inherits:
Group
  • Object
show all
Defined in:
lib/transaction/simple/threadsafe/group.rb

Overview

A transaction group is an object wrapper that manages a group of objects as if they were a single object for the purpose of transaction management. All transactions for this group of objects should be performed against the transaction group object, not against individual objects in the group. This is the threadsafe version of a transaction group.

Instance Attribute Summary

Attributes inherited from Group

#objects

Instance Method Summary collapse

Methods inherited from Group

#abort_transaction, #clear, #commit_transaction, #rewind_transaction, #start_transaction, #transaction, #transaction_name, #transaction_open?

Constructor Details

#initialize(*objects) ⇒ Group

Returns a new instance of Group.



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/transaction/simple/threadsafe/group.rb', line 11

def initialize(*objects)
  @objects = objects || []
  @objects.freeze
  @objects.each { |obj| obj.extend(Transaction::Simple::ThreadSafe) }

  if block_given?
    begin
      yield self
    ensure
      self.clear
    end
  end
end