lib/builder/xmlbase.rb in builder-2.0.0 vs lib/builder/xmlbase.rb in builder-2.1.1

- old
+ new

@@ -37,41 +37,40 @@ def method_missing(sym, *args, &block) text = nil attrs = nil sym = "#{sym}:#{args.shift}" if args.first.kind_of?(Symbol) args.each do |arg| - case arg - when Hash - attrs ||= {} - attrs.merge!(arg) - else - text ||= '' - text << arg.to_s - end + case arg + when Hash + attrs ||= {} + attrs.merge!(arg) + else + text ||= '' + text << arg.to_s + end end if block - unless text.nil? - raise ArgumentError, "XmlMarkup cannot mix a text argument with a block" - end - _capture_outer_self(block) if @self.nil? - _indent - _start_tag(sym, attrs) - _newline - _nested_structures(block) - _indent - _end_tag(sym) - _newline + unless text.nil? + raise ArgumentError, "XmlMarkup cannot mix a text argument with a block" + end + _indent + _start_tag(sym, attrs) + _newline + _nested_structures(block) + _indent + _end_tag(sym) + _newline elsif text.nil? - _indent - _start_tag(sym, attrs, true) - _newline + _indent + _start_tag(sym, attrs, true) + _newline else - _indent - _start_tag(sym, attrs) - text! text - _end_tag(sym) - _newline + _indent + _start_tag(sym, attrs) + text! text + _end_tag(sym) + _newline end @target end # Append text to the output target. Escape any markup. May be @@ -118,13 +117,9 @@ def _escape_quote(text) _escape(text).gsub(%r{"}, '&quot;') # " WART end - def _capture_outer_self(block) - @self = eval("self", block) - end - def _newline return if @indent == 0 text! "\n" end