lib/builder/xmlbase.rb in builder-1.1.0 vs lib/builder/xmlbase.rb in builder-1.2.0
- old
+ new
@@ -11,11 +11,11 @@
# Builder::XmlMarkup and Builder::XmlEvents for examples.
class XmlBase < BlankSlate
# Create an XML markup builder.
#
- # out:: Object receiving the markup. +out+ must respond to
+ # out:: Object receiving the markup.1 +out+ must respond to
# <tt><<</tt>.
# indent:: Number of spaces used for indentation (0 implies no
# indentation and no line breaks).
# initial:: Level of initial indentation.
#
@@ -35,10 +35,11 @@
# is never invoked directly, but is called for each markup method
# in the markup block.
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)
@@ -99,10 +100,12 @@
end
# For some reason, nil? is sent to the XmlMarkup object. If nil?
# is not defined and method_missing is invoked, some strange kind
# of recursion happens. Since nil? won't ever be an XML tag, it
- # is pretty safe to define it here.
+ # is pretty safe to define it here. (Note: this is an example of
+ # cargo cult programming,
+ # cf. http://fishbowl.pastiche.org/2004/10/13/cargo_cult_programming).
def nil?
false
end
private