37: def method_missing(sym, *args, &block)
38: text = nil
39: attrs = nil
40: sym = "#{sym}:#{args.shift}" if args.first.kind_of?(Symbol)
41: args.each do |arg|
42: case arg
43: when Hash
44: attrs ||= {}
45: attrs.merge!(arg)
46: else
47: text ||= ''
48: text << arg.to_s
49: end
50: end
51: if block
52: unless text.nil?
53: raise ArgumentError, "XmlMarkup cannot mix a text argument with a block"
54: end
55: _indent
56: _start_tag(sym, attrs)
57: _newline
58: _nested_structures(block)
59: _indent
60: _end_tag(sym)
61: _newline
62: elsif text.nil?
63: _indent
64: _start_tag(sym, attrs, true)
65: _newline
66: else
67: _indent
68: _start_tag(sym, attrs)
69: text! text
70: _end_tag(sym)
71: _newline
72: end
73: @target
74: end