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