An interesting variation on OpenStruct. In my work with such things
I've found that defined methods to return the values is slowere then
just using a lookup table. But in this case I think it would not be
since the dyanmic value needs to be evaluated.

What can one do with it? Well, for starters it provides an interesting
alternative as the bases of prototype-based Ruby programming
--something I've been playng with.

 ...

 def add_member(name, new_proc)
    instance_variable_set( "@#{name}", new_proc }
    self.instance_eval %{
      def #{name}
        #{new_proc}
      end
    }
  end

  def new
    o=OpenClass.new
    instance_variables.each { |iv|
      o.add_member( iv.gsub(/^@/,''), instance_variable_get(iv) )
    }
    yield(o) if block_given?
    o
  end

  def open
    yield(self) if block_given?
    self
  end

  ...

  def obj
    o=OpenClass.new
    yield(o)
    o
  end

  myobj = obj { |o|
    o.test_method = %{ puts "test" }
  }

  myobj2 = myobj.new { |o|
    o.test_method2 = %{ puts "test2" }
  }

  myobj2.open { |o|
    o.test_method3 = %{ puts "test3" }
  }

Unfortuately Ruby has no way to close off block scopes, so all these
blocks are wide open to main.

T.