[ANN] Transaction::Simple 1.1.0

A

Austin Ziegler

I am pleased to announce the release of Transaction::Simple 1.1.0.

Transaction::Simple provides a generic way to add active transactional
support to objects. The transaction methods added by this module will work
with most objects, excluding those that cannot be Marshal-ed (bindings,
procedure objects, IO instances, or singleton objects).

The transactions supported by Transaction::Simple are not backend
transaction; that is, they have nothing to do with any sort of data store.
They are "live" transactions occurring in memory and in the object itself.
This is to allow "test" changes to be made to an object before making the
changes permanent.

Transaction::Simple can handle an "infinite" number of transactional levels
(limited only by memory). If I open two transactions, commit the first, but
abort the second, the object will revert to the original version.

The major changes from 1.0 are the addition of an explicitly thread-safe
version (Transaction::Simple::ThreadSafe), and the addition of named
transactions. Named transactions work in some ways similar to Ruby's
catch/throw construct, allowing the commit, abort, or rewind of transactions
multiple levels deep without manually acting on the intervening
transactions.

Named Transaction Usage
-----------------------
v = "Hello, you." # => "Hello, you."
v.extend(Transaction::Simple) # => "Hello, you."

v.start_transaction:)first) # => ... (a Marshal string)
v.transaction_open? # => true
v.transaction_open?:)first) # => true
v.transaction_open?:)second) # => false
v.gsub!(/you/, "world") # => "Hello, world."

v.start_transaction:)second) # => ... (a Marshal string)
v.gsub!(/world/, "HAL") # => "Hello, HAL."
v.rewind_transaction:)first) # => "Hello, you."
v.transaction_open? # => true
v.transaction_open?:)first) # => true
v.transaction_open?:)second) # => false

v.gsub!(/you/, "world") # => "Hello, world."
v.start_transaction:)second) # => ... (a Marshal string)
v.gsub!(/world/, "HAL") # => "Hello, HAL."
v.transaction_name # => :second
v.abort_transaction:)first) # => "Hello, you."
v.transaction_open? # => false

v.start_transaction:)first) # => ... (a Marshal string)
v.gsub!(/you/, "world") # => "Hello, world."
v.start_transaction:)second) # => ... (a Marshal string)
v.gsub!(/world/, "HAL") # => "Hello, HAL."

v.commit_transaction:)first) # => "Hello, HAL."
v.transaction_open? # => false

Copyright: Copyright © 2003 by Austin Ziegler
Version: 1.1
Licence: MIT-Style

Thanks to David Black and Mauricio Fernández for their help with different
aspects of this library.

The MD5 hash of the archive is:
Digest::MD5.new(File.read('transaction-simple-1.1.0.tar.gz'))
=> 4396b92176ce4fc42f7219857e270bcb

-austin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top