Question: I want to do some validation whenever the value of a textfield changes. I don't see an on change event mentioned in the documentation though.

Answer: 
Simply marshalling the object (as others have said) wont work. Lets look at an example. Consider this class:

```
class Extras
  attr_accessor :contents
  def test
    puts "This instance of Extras is OK. Contents is: " + @contents.to_s
  end

  def add_method( name )
    self.class.send :define_method, name.to_sym do
      puts "Called " + name.to_s
    end
  end
end

```

Now lets write a program which creates an instance, adds a method to it and saves it to disk:

```
require 'extras'

fresh = Extras.new
fresh.contents = 314
fresh.test # outputs "This instance of Extras is OK. Contents is: 314"
fresh.add_method( :foo )
fresh.foo # outputs "Called foo"

serial = Marshal.dump( fresh )
file = File.new "dumpedExample", 'w'
file.write serial

```

So we can call the normal method 'test' and the dynamic method 'foo'. Lets look at what happens if we write a program which loads the instance of Example which was saved to disk:

```
require 'extras'

file = File.new 'dumpedExample', 'r'
serial = file.read

reheated = Marshal.load( serial )
reheated.test # outputs "This instance of Extras is OK. Contents is 314"
reheated.foo # throws a NoMethodError exception 

```

So we can see that while the instance (including the values of member variables) was saved the dynamic method was not.

From a design point of view it's probably better to put all your added code into a module and load that into the class again when you next run the program. We'd need a good example of how you might want to use it though to really know this.

If you need extra information to recreate the methods then have the module save these as member variables. Implement `included` in the module and have it look for these member variables when it is included into the class.
<http://ruby-doc.org/core/classes/Marshal.html>