builder
builder copied to clipboard
Builder method_missing overrides even Object and Kernel methods
The XmlMarkup
class overrides any method that is not part of its class, including Object and/or Kernel methods.
Simple examples:
[2] DEVELOPMENT(main)> xml = Builder::XmlMarkup.new
=> <is_a?>String</is_a?><inspect/>
I'm thinking that the is_a?
method is being applied because irb
is evaluating the argument.
[3] DEVELOPMENT(main)> puts xml.inspect
<is_a?>String</is_a?><inspect/><inspect/>
=> nil
Yep. An explicit use of inspect
causes another tag to be inserted.
It should be possible to use Ruby's Object and/or Kernel methods on an XmlMarkup
instance without getting matching tags automatically inserted.
Some exceptions, like p
and name
, may need to be allowed, since those methods might also be common tags.