[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

General Purpose Transactions

T. Onoma

11/14/2003 12:30:00 AM

I was writing a piece a code where I needed to change a few object attributes, call a method, then reset those attributes to what they were. And it occured to me that it might be nice to have general purpose tranactions.


anobject = AClass.new
anobject.attrib = 'set'
transaction do
anobject.attrib = 'temp'
anobject.amethod
end
p anobject.attrib # => 'set'


Seems like there may already be a simple way to do this, but it's not coming to mind.

-t0

2 Answers

Gavin Sinclair

11/14/2003 12:54:00 AM

0

On Friday, November 14, 2003, 11:30:26 AM, T. wrote:

> I was writing a piece a code where I needed to change a few object attributes, call a method, then reset those attributes to what they were. And it occured to me that it might be nice to have
> general purpose tranactions.


> anobject = AClass.new
> anobject.attrib = 'set'
> transaction do
> anobject.attrib = 'temp'
> anobject.amethod
> end
> p anobject.attrib # => 'set'


> Seems like there may already be a simple way to do this, but it's not coming to mind.

Austin Ziegler's Transaction::Simple will help, with slightly
different semantics, I think. Search the RAA for it.

Gavin


Ara.T.Howard

11/14/2003 1:29:00 AM

0