Skip to content

Builder method_missing overrides even Object and Kernel methods #18

Open
@aks

Description

@aks

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions