This works for me

class XmlDoc
  def method_missing(name, *args, &block)
    self.class.class_eval do
      define_method(name) do |*args, &block|
        if block_given?
          temp = "<#{name}#{temp}>" + yield + "</#{name}>"
        else
          "<#{name}></#{name}>"
        end
      end
    end
    send(name, *args, &block)
  end
end

x = XmlDoc.new
p x.hello{ "dolly" }

-- 
Posted via http://www.ruby-forum.com/.