diff --git a/lib/builder/xmlbase.rb b/lib/builder/xmlbase.rb index 2cddbec..14b7c69 100644 --- a/lib/builder/xmlbase.rb +++ b/lib/builder/xmlbase.rb @@ -6,8 +6,17 @@ module Builder # Generic error for builder class IllegalBlockError < RuntimeError; end - # XmlBase is a base class for building XML builders. See + # XmlBase is a base class for building XML builders. See # Builder::XmlMarkup and Builder::XmlEvents for examples. + # + # Please note, that the XmlBase class inherits from +BasicObject+, + # not from the more common +Object+. The advantage is that there are less + # instance methods which can conflict with xml element names which + # might be used. The disadvantage is that these +Object+ instance + # methods might be expected to be present by testing tools + # or IRB or other consoles for inspection. + # Prominent missing methods are: +class+, +display+, +hash+, +inspect+, + # +methods+, +object_id+, +send+ (you can use +__send__+ though). class XmlBase < BasicObject class << self @@ -16,8 +25,6 @@ class << self # Create an XML markup builder. # - # out :: Object receiving the markup. +out+ must respond to - # <<. # indent :: Number of spaces used for indentation (0 implies no # indentation and no line breaks). # initial :: Level of initial indentation. @@ -117,12 +124,9 @@ def <<(text) _text(text) 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. (Note: this is an example of - # cargo cult programming, - # cf. http://fishbowl.pastiche.org/2004/10/13/cargo_cult_programming). + # +nil?+ is an instance method not implemented on the +BasicObject+, + # but since +nil?+ won't ever be an XML tag, it is pretty safe to + # define it here. def nil? false end diff --git a/lib/builder/xmlmarkup.rb b/lib/builder/xmlmarkup.rb index cccf8d0..432b2bd 100644 --- a/lib/builder/xmlmarkup.rb +++ b/lib/builder/xmlmarkup.rb @@ -16,9 +16,9 @@ module Builder - # Create XML markup easily. All (well, almost all) methods sent to - # an XmlMarkup object will be translated to the equivalent XML - # markup. Any method with a block will be treated as an XML markup + # Create XML markup easily. All methods (except BasicObject instance methods) + # sent to an XmlMarkup object will be translated to the equivalent XML + # markup. Any method with a block will be treated as an XML markup # tag with nested markup in the block. # # Examples will demonstrate this easier than words. In the @@ -57,7 +57,7 @@ module Builder # # xm.div { #