Patrick Li wrote:
> I currently have a rather inelegant hack using instance_eval, which
> messes up a lot of other things.

If you want to avoid instance_eval (and that's a good idea for DSL 
syntax in many cases, IMO), one alternative is to use yield to get 
syntax like:

string = Farm.create do |farm|
   farm.barn do |barn|
     barn.animal "dog"
     barn.animal "cat"
   end
   farm.pond do |pond|
     pond.animal "whale"
     pond.animal "shark"
   end
end

A little less concise, but you avoid the scope changes that come with 
instance_eval.

-- 
       vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407