# Class/method definitions, transactions and undo

**URL:** <https://www.ruby-forum.com/t/class-method-definitions-transactions-and-undo/68945>\
**Category:** Ruby\
**Created:** [February 15, 2006, 11:39pm UTC](https://www.ruby-forum.com/t/class-method-definitions-transactions-and-undo/68945 "2006-02-15T23:39:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marcin\_MielSSS\_ySSS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ee7513/32.png) [@Marcin\_MielSSS\_ySSS](https://www.ruby-forum.com/u/Marcin_MielSSS_ySSS)\
**Post date:** [February 15, 2006, 11:39pm UTC](https://www.ruby-forum.com/t/class-method-definitions-transactions-and-undo/68945/1 "2006-02-15T23:39:20Z")

</div>

Hi  
I wonder what would be the easiest way to create transactional/undoable  
modifications to Ruby’s method, classes, hierarchies…

I started with

class C  
def C.method\_added m  
p C.instance\_methods(false)  
end  
end

p C.instance\_methods(false)

class C  
def new\_method

```
 end

```

end

C.class\_eval{  
define\_method :new\_method2 do |\*args|  
end  
}

-\>  
[]  
[“new\_method”]  
[“new\_method2”, “new\_method”]

but it seems that method\_added is called after methods additions, so  
there is no way to alias and save it into an array to achieve some kind  
of history…

any clues ?

lopex
